The use of Text function in getting the day and month from the given date

Excel Tip #001

The use of Text function in getting the day and month from the given date

Sometimes we may want to know the day and month of the given date. In such cases, we can make use of the TEXT function to retrieve the information.

The formula to show current date is using TODAY() function.

=TODAY()

The functionality of TEXT function is to convert a value to text in a specific number format. Here we are going to use the same function to convert date into days & months.

=TEXT(value,format_text)

In the value field, we are going to assign a date and in format_text field we can define d, m (or) y (date, month & year respectively) based on the output that we are expecting.

Let us now consider the date 6/15/2014 (June 15, 2014) which is the value field. This date is defined in the cell B2 in my excel.

Assigning format_text "dddd" will return the day of the date.
          Formula: =TEXT(B2,"dddd")
Assigning format_text "ddd" will return the first 3 letter of the day.
          Formula: =TEXT(B2,"ddd")
Assigning format_text "dd" will return the date.
          Formula: =TEXT(B2,"dd")

Below snapshot shows the value returned for the 3 different formula assigned in Column C.
Retrieving date values using Text function

Similarly, we can show the month values.

Assigning format_text "mmmm" will return the month.
          Formula: =TEXT(B2,"mmmm")
Assigning format_text "mmm" will return the first 3 letter of the month.
          Formula: =TEXT(B2,"mmm")
Assigning format_text "mm" will return the month number.
          Formula: =TEXT(B2,"mm")

Retrieving month values using Text function

Below we can see the same for year values.

Assigning format_text "yyyy" will return the year.
          Formula: =TEXT(B2,"yyyy")
Assigning format_text "yyy" will return the year.
          Formula: =TEXT(B2,"yyy")
Assigning format_text "yy" will return the last 3 digits of the year.
          Formula: =TEXT(B2,"yy")

Here for format_text values, "yyyy" and "yyy" returns the same value - 2014.

Retrieving year values using Text function

Comments

Popular posts from this blog

VLOOKUP - Exact Match & Approximate Match

Row 1 Is Missing. How to unhide?

Search Backwards in Excel