Insert this formula in cell B2 (of our sample dataset) and copy it down to the rest of the cells in column B. Note: Always remember to enclose the format_code in quotes.
Excel formatting formula for date and text code#
The TEXT function applies this format code to the specified date_input and it returns a text string in the given format.įor example, the following formula takes the date provided in cell A2 and returns the date “1/1/21”: =TEXT(A2,”m/d/yy”) These format codes are the same as the codes discussed in Method 2. date_format_code is the format code that specifies how you want the resulting date to look.date_input is the date value or a reference to a cell containing a date that you want to apply the Short Date format to.The syntax for the TEXT function is: = TEXT ( date_input, date_format_code) It takes a DATE value and lets you format it according to a given format code.
The TEXT function lets you convert dates to different text formats. If, however, you want to keep the original date(s) in the Long format as is and display the Short format in a separate cell, then you can use the TEXT function. The first two methods apply the Short Date format to the original cell(s). Method 3: Using the TEXT Function to Apply Short Date Format in Excel Here are a few example date formats that are commonly used: Format You can combine the above codes to create your required short-date format. Here are some of the codes that you can use: Code To display the month number with a leading zero, on the other hand, you can use the “mm” code. For example, to represent the month number without a leading zero, you can use the “m” code. Your customized format needs to follow certain rules.