The first part of our tutorial focuses of formatting dates in Excel and explains how to set the default date and time formats, how to change date format in Excel, how to create custom date formatting, and convert your dates to another locale.
Along with numbers, dates and times are the most common data types people use in Excel. However, they may be quite confusing to work with, firstly, because the same date can be displayed in Excel in a variety of ways, and secondly, because Excel always internally stores dates in the same format regardless of how you have formatted a date in a given cell.
Knowing the Excel date formats a little in depth can help you save a ton of your time. And this is exactly the aim of our comprehensive tutorial to working with dates in Excel. In the first part, we will be focusing on the following features:
Excel date format
Before you can take advantage of powerful Excel date features, you have to understand how Microsoft Excel stores dates and times, because this is the main source of confusion. While you would expect Excel to remember the day, month and the year for a date, that's not how it works...
Excel stores dates as sequential numbers and it is only a cell's formatting that causes a number to be displayed as a date, time, or date and time.
Dates in Excel
All dates are stored as integers representing the number of days since January 1, 1900, which is stored as number 1, to December 31, 9999 stored as 2958465.
In this system:
- 2 is 2-Jan-1900
- 3 is 3-Jan-1900
- 42005 is 1-Jan-2015 (because it is 42,005 days after January 1, 1900)
Time in Excel
Times are stored in Excel as decimals, between .0 and .99999, that represent a proportion of the day where .0 is 00:00:00 and .99999 is 23:59:59.
For example:
- 0.25 is 06:00 AM
- 0.5 is 12:00 PM
- 0.541655093 is 12:59:59 PM
Dates & Times in Excel
Excel stores dates and times as decimal numbers comprised of an integer representing the date and a decimal portion representing the time.
For example:
- 1.25 is January 1, 1900 6:00 AM
- 42005.5 is January 1, 2015 12:00 PM
How to convert date to number in Excel
If you want to know what serial number represents a certain date or time displayed in a cell, you can do this in two ways.
1. Format Cells dialog
Select the cell with a date in Excel, press Ctrl+1 to open the Format Cells window and switch to the General tab.
If you just want to know the serial number behind the date, without actually converting date to number, write down the number you see under Sample and click Cancel to close the window. If you want to replace the date with the number in a cell, click OK.
2. Excel DATEVALUE and TIMEVALUE functions
Use the DATEVALUE() function to convert an Excel date to a serial number, for example =DATEVALUE("1/1/2015")
.
Use the TIMEVALUE() function to get the decimal number representing the time, for example =TIMEVALUE("6:30 AM")
.
To know both, date and time, concatenate these two functions in the following way:
=DATEVALUE("1/1/2015") & TIMEVALUE("6:00 AM")
Note. Since Excel's serial numbers begins on January 1, 1900 and negative numbers aren't recognized, dates prior to the year 1900 are not supported in Excel.
If you enter such a date in a sheet, say 12/31/1899, it will be a text value rather than a date, meaning that you cannot perform usual date arithmetic on early dates. To make sure, you can type the formula =DATEVALUE("12/31/1899")
in some cell, and you will get an anticipated result - the #VALUE! error.
If you are dealing with date and time values and you'd like to convert time to decimal number, please check out the formulas described in this tutorial: How to convert time to decimal number in Excel.
Default date format in Excel
When you work with dates in Excel, the short and long date formats are retrieved from your Windows Regional settings. These default formats are marked with an asterisk (*) in the Format Cell dialog window:
The default date and time formats in the Format Cell box change as soon as you change the date and time settings in Control Panel, which leads us right to the next section.
How to change the default date and time formats in Excel
If you want to set a different default date and/or time formats on your computer, for example change the USA date format to the UK style, go to Control panel and click Region and Language. If in your Control panel opens in Category view, then click Clock, Language, and Region > Region and Language > Change the date, time, or number format.
On the Formats tab, choose the region under Format, and then set the date and time formatting by clicking on an arrow next to the format you want to change and selecting the desired one from the drop-down list:
Tip. If you are not sure what different codes (such as mmm, ddd, yyy) mean, click the "What does the notation mean" link under the Date and time formats section, or check the Custom Excel date formats in this tutorial.
If you are not happy with any time and date format available on the Formats tab, click the Additional settings button in the lower right-hand side of the Region and Language dialog window. This will open the Customize dialog, where you switch to the Date tab and enter a custom short or/and long date format in the corresponding box.
How to quickly apply default date and time formatting in Excel
Microsoft Excel has two default formats for dates and time - short and long, as explained in default Excel date format.
To quickly change date format in Excel to the default formatting, do the following:
- Select the dates you want to format.
- On the Home tab, in the Number group, click the little arrow next to the Number Format box, and select the desired format - short date, long date or time.
If you want more date formatting options, either select More Number Formats from the drop-down list or click the Dialog Box Launcher next to Number. This will open a familiar Format Cells dialog and you can change date format there.
Tip. If you want to quickly set date format in Excel to dd-mmm-yy, press Ctrl+Shift+#. Just keep in mind that this shortcut always applies the dd-mmm-yy format, like 01-Jan-15, regardless of your Windows Region settings.
How to change date format in Excel
In Microsoft Excel, dates can be displayed in a variety of ways. When it comes to changing date format of a given cell or range of cells, the easiest way is to open the Format Cells dialog and choose one of the predefined formats.
- Select the dates whose format your want to change, or empty cells where you want to insert dates.
- Press Ctrl+1 to open the Format Cells dialog. Alternatively, you can right click the selected cells and choose Format Cells… from the context menu.
- In the Format Cells window, switch to the Number tab, and select Date in the Category list.
- Under Type, pick a desired date format. Once you do this, the Sample box will display the format preview with the first date in your selected data.
- If you are happy for the preview, click the OK button to save the format change and close the window.
If the date format is not changing in your Excel sheet, most likely your dates are formatted as text and you have to convert them to the date format first.
How to convert date format to another locale
Once you've got a file full of foreign dates and you would most likely want to change them to the date format used in your part of the world. Let's say, you want to convert an American date format (month/day/year) to a European style format (day/month/year).
The easiest way to change date format in Excel based on how another language displays dates is as follows:
- Select the column of dates you want to convert to another locale.
- Press Ctrl+1 to open the Format Cells
- Select the language you want under Locale (location) and click OK to save the change.
If you want the dates to be displayed in another language, then you will have to create a custom date format with a locale code.
Creating a custom date format in Excel
If none of the predefined Excel date formats is suitable for you, you are free to create your own.
- In an Excel sheet, select the cells you want to format.
- Press Ctrl+1 to open the Format Cells dialog.
- On the Number tab, select Custom from the Category list and type the date format you want in the Type box.
- Click OK to save the changes.
Tip. The easiest way to set a custom date format in Excel is to start from an existing format close to what you want. To do this, click Date in the Category list first, and select one of existing formats under Type. After that click Custom and make changes to the format displayed in the Type box.
When setting up a custom date format in Excel, you can use the following codes.
Code | Description | Example (January 1, 2005) |
m | Month number without a leading zero | 1 |
mm | Month number with a leading zero | 01 |
mmm | Month name, short form | Jan |
mmmm | Month name, full form | January |
mmmmm | Month as the first letter | J (stands for January, June and July) |
d | Day number without a leading zero | 1 |
dd | Day number with a leading zero | 01 |
ddd | Day of the week, short form | Mon |
dddd | Day of the week, full form | Monday |
yy | Year (last 2 digits) | 05 |
yyyy | Year (4 digits) | 2005 |
When setting up a custom time format in Excel, you can use the following codes.
Code | Description | Displays as |
h | Hours without a leading zero | 0-23 |
hh | Hours with a leading zero | 00-23 |
m | Minutes without a leading zero | 0-59 |
mm | Minutes with a leading zero | 00-59 |
s | Seconds without a leading zero | 0-59 |
ss | Seconds with a leading zero | 00-59 |
AM/PM | Periods of the day (if omitted, 24-hour time format is used) |
AM or PM |
To set up date and time format, include both date and time units in your format code, e.g. m/d/yyyy h:mm AM/PM. When you use "m" immediately after "hh" or "h" or immediately before "ss" or "s", Excel will display minutes, not a month.
When creating a custom date format in Excel, you can use a comma (,) dash (-), slash (/), colon (:) and other characters.
For example, the same date and time, say January 13, 2015 13:03, can be displayed in a various ways:
Format | Displays as |
dd-mmm-yy | 13-Jan-15 |
mm/dd/yyyy | 01/13/2015 |
m/dd/yy | 1/13/15 |
dddd, m/d/yy h:mm AM/PM | Tuesday, 1/13/15 1:03 PM |
ddd, mmmm dd, yyyy hh:mm:ss | Tue, January 13, 2015 13:03:00 |
Tip. Using a custom date format, you can easily display the day of the week from date.
How to create a custom Excel date format for another locale
If you want to display dates in another language, you have to create a custom format and prefix a date with a corresponding locale code. The locale code should be enclosed in [square brackets] and preceded with the dollar sign ($) and a dash (-). Here are a few examples:
- [$-409] - English, Untitled States
- [$-1009] - English, Canada
- [$-407] - German, Germany
- [$-807] - German, Switzerland
- [$-804] - Bengali, India
- [$-804] - Chinese, China
- [$-404] - Chinese, Taiwan
You can find the full list of locale codes on this blog.
For example, this is how you set up a custom Excel date format for the Chinese locale in the year-month-day (day of the week) time format:
The following image shows a few examples of the same date formatted with different locale codes in the way traditional for the corresponding languages:
Excel date format not working - fixes and solutions
Usually, Microsoft Excel understands dates very well and you are unlikely to hit any roadblock when working with them. If you happen to have an Excel date format problem, please check out the following troubleshooting tips.
A cell is not wide enough to fit an entire date
If you see a number of pound signs (#####) instead of dates in your Excel worksheet, most likely your cells are not wide enough to fit the whole dates.
Solution. Double-click the right border of the column to resize it to auto fit the dates. Alternatively, you can drag the right border to set the column width you want. For more details, see How to fix #### error in Excel.
Negative numbers are formatted as dates
Hash marks (#####) are also displayed when a cell formatted as a date or time contains a negative value. Usually it's a result returned by some formula, but it may also happen when you type a negative value into a cell and then format that cell as a date.
If you want to display negative numbers as negative dates, two options are available to you:
Solution 1. Switch to the 1904 date system.
Go to File > Options > Advanced, scroll down to the When calculating this workbook section, select the Use 1904 date system check box, and click OK.
In this system, 0 is 1-Jan-1904; 1 is 2-Jan-1904; and -1 is displayed as a negative date -2-Jan-1904.
Of course, such representation is very unusual and takes time to get used to, but this is the right way to go if you want to perform calculations with early dates.
Solution 2. Use the Excel TEXT function.
Another possible way to display negative numbers as negative dates in Excel is using the TEXT function. For example, if you are subtracting C1 from B1 and a value in C1 is greater than in B1, you can use the following formula to output the result in the date format:
=TEXT(ABS(B1-C1),"-d-mmm-yyyy")
You may want to change the cell alignment to right justified, and naturally, you can use any other custom date formats in the TEXT formula.
Note. Unlike the previous solution, the TEXT function returns a text value, that is why you won't be able to use the result in other calculations.
Dates are imported to Excel as text values
When you are importing data to Excel from a .csv file or some other external database, dates are often imported as text values. They may look like normal dates to you, but Excel perceives them as text and treats accordingly.
Solution. You can convert "text dates" to the date format using Excel's DATEVALUE function or Text to Columns feature. Please see the following article for full details: How to convert text to date in Excel.
Tip. If none of the above tips worked for you, then try to remove all formatting and then set the desired date format.
This is how you format dates in Excel. In the next part of our guide, we will discuss various ways of how you can insert dates and times in your Excel worksheets. Thank you for reading and see you next week!
934 comments
I need to calculate negative days for calculating dates. When I use this formula =DATEDIF(A1, TODAY(), "d") and A1 is 6/22/2020 but TODAY is 6/19/2020 the calculation cell shows #NUM! but I need it to show -3. Can't figure out the formula. Any help would be great.
Hello Stan!
You do not need to change the date format. You need to add the condition to the formula.
If I understand your task correctly, the following formula should work for you:
=IF(A1>TODAY(),-DATEDIF(TODAY(),A1,"d"),DATEDIF(A1, TODAY(),"d"))
I hope my advice will help you solve your task.
Hi, I have two different time with 12 hours format in two cells. The second cell required to covert for 24 hours format and the time difference between the two cell has to written in third cell.
Hello!
I did not understand what your problem is. To find the time difference between cells, the time format does not matter. The time format affects the appearance of the cell, not its value. Write an example of the source data and the result you want to get.
Hello sir,
I want to convert 2013.583 to date. Please help me
Hello!
What date do you want to get from 2013.583? i can't guess
Sir, I want date separator "-" not "/" I have done almost everything but I am not getting desired results. My date format is dd-mm-yyyy whereas it is showing dd/mm/yyyy. Please help.
Sorry forget to mention I can not insert any formula please.
Hello Kataria!
As a date separator symbol, Excel uses the symbol that is specified in Control Panel -> Clock and region -> Region -> Formats -> Additional Settings -> Date and Time formats.
Or use a custom format:
Please go to Format Cells, choose Number -> Custom Format and set
dd-mm-yyyy
Hello, can I set the date as below
01-Mar-Y1
Y1 indicates 2021.
Is it possible ?
Hello Aida!
This date format is not possible. However, you can convert the date to text.
In this case, you can apply a custom date format. Use the formula
=TEXT(G1,"dd-mmm-")&"Y"&RIGHT(G1,1)
I hope my advice will help you solve your task.
Hi
I have a date issue where by in a cell with text & long date & need to convert into short date by MONTH/DAY/YEAR? This is a two formula process. BELOW IS THE TWO FORMULA'S
1 = Randwick Saturday, 06 June 2020 =MID(Z6,MIN(IFERROR(MIN(FIND({0,1,2,3,4,5,6,7,8,9},Z6&"0123456789",1)),LEN(Z6)+1)),LOOKUP(1,0*MID(Z6,ROW(INDIRECT("1:"&LEN(Z6))),1),ROW(INDIRECT("1:"&LEN(Z6))))+1)
Returns = 06 June 2020
2 =DATE(RIGHT(Z1,4),RIGHT(LEFT(Z1,2),2),LEFT(Z1,2))
now converting to MONTH/DAY/YEAR
= 6/06/1920
This returns wrong year!
Any help would be greatly appreciated
Regards
Tony
I assume that after the phrase Randwick Saturday, 06 June 2020, you still have a space. As a result, the text 06 June 2020 also has a space, that is, “06 June 2020”.
I recommend checking this or using a formula with the TRIM function:
=TRIM(MID(Z6,MIN(IFERROR(MIN( FIND({0,1,2,3,4,5,6,7,8,9},Z6&"0123456789",1)), LEN(Z6)+1)), LOOKUP(1,0*MID(Z6,ROW(INDIRECT("1:"&LEN(Z6))),1), ROW(INDIRECT("1:"&LEN(Z6))))+1))
Now the date format function will work correctly.
Hi Alexander
I tried the formula but still didn't get the date 6-06-2020.
Hi Alexander
Sorry I got cut off, but to finish.
There is a space between all texts & date plus at the end of years as well.
In the formula there has space in where FIND, LEN & LOOKUP is, so cancel space ,but still didn't work. Tried { } as well.
Regards
Tony
Hello!
I used your formulas and copied the text from your message. As I understand it, the first formula is written in cell Z1.
=TRIM(MID(Z6, MIN(IFERROR(MIN(FIND({0,1,2,3,4,5,6,7,8,9},Z6&"0123456789",1)), LEN(Z6)+1)), LOOKUP(1,0*MID(Z6,ROW(INDIRECT("1:"&LEN(Z6))),1), ROW(INDIRECT("1:"&LEN(Z6))))+1))
My second formula works when the formula is written in Z1
I noticed that your second formula incorrectly determines the month. Use this formula
=DATEVALUE(LEFT(Z1,2)&"-"&MID(Z1,4,3)&"-"&RIGHT(Z1,4))
Hi Alexander
Works like a dream, thank you.
One question with the date formula, how does it read the month without the 0 for the 6 month?
Regards
Tony
Hello Tony!
The function reads the first three letters in the name of the month. She receives the text "06-Jun-2020", which is converted to a date using the DATEVALUE function.
Hi Alexander
Sorry again, but how do you put month first?
Month / Day / Year
Regards
Tony
Yello again!
The date display format depends on the regional settings of your Windows and the date format in Excel. Read above in this article about custom date formats.
Hello!
I am trying to sort my information by year. I already tried the custom format option provided above and it has been applied to all the fields. However, when I go the filter and try to sort the info by year, it will only work on half of the column. It seems as if some of the fields didn't recognize the custom format even though I already made sure that it was applied to all the data. Is there anything I can do?
Hello Karina!
I can assume that in some cells of your table the date is written as text. Typically, the text in such cells is left-justified, and the real date is right-justified. Check cells that you cannot sort correctly. Read how to convert text to date in this article. I hope my advice will help you solve your task.
Does anyone find it very odd that an extremely common date format like 01-Jan-2020 isn't available unless you add it as a custom dd-mmm-yyyy ?
I would like to change the dates of a whole spreadsheet by only changing the first date, is that possible and can someone help me with the formula please? I would like to change 01.06.2020 and would like the rest of the dates to add 1 more day so I do not have to type the dates everytime I use it for the following month.
Hello!
If I understand your task correctly, the first date in cell A1. In cell A2 have the formula
=A1+1
After that you can copy this formula down along the column.
HAI
I HAD A PROBLEM IN EXCEL THAT I HAVE TO SUBMIT A REPORT TO OFFICE.
if I ENTER STARTING TIME AND TOTAL TRIPS DONE IN A DAY ( 5.30AM AND TRIPS DONE 5) SO, HOW TO CALCULATE THE ENDING TIME.
(Sl.No DATE STARTING TIME END TIME TOTAL TRIPS WARD NO. / AREA FUEL IN TANK FUEL SUPPLIED FUEL CONSUMED BALANCE IN TANK
1 01-May 5.30 AM 2.30 PM 6 0 50 18 32
2 02-May 6.30 AM 5.00 PM 0 32 0 32
3 03-May 5.00 AM 12.30 PM 0 32 0 32
4 04-May 5.30 AM 1.00 PM 0 32 0 32 )
IF I CHANGE TRIPS THEN THE ENDING TIME SHOULD BE CHANGE. CAN I GET SOME FORMULA TO DO MY WORK FAST
Hello!
Please describe your problem in more detail. What exactly do you change on a trip? What determines the end time of a trip? How do you want to calculate it? Write an example of the source data and the result you want to get. It’ll help me understand it better and find a solution for you. Thank you.
Is there a 'switch' for date formats to force uppercase text?
I am trying to display 'April 2020' (mmmm yyyy) as 'APRIL 2020' without the use of =upper() function as the date needs to be displayed this way in the same cell as it is entered.
Thanks
Hello Dave!
You can capitalize the first letter of the month using the "MMMM yyyy" format. You can write the name of the month in capital letters without using formulas using VBA only.
Hi how can I change a field value from "Aug 10 1984 12:00AM" to
"1984/08/10"(yyyy/mm/dd)
Normal format "date" is not working
Hello Mel!
Your value "Aug 10 1984 12:00AM" is the text. Therefore, turning it into a date can only be done using a formula.
=DATEVALUE(SUBSTITUTE(MID(T1,5,3)&REPLACE(LEFT(T1,11),5,3,"")," ","/")) + TIMEVALUE(RIGHT(SUBSTITUTE(T1,"AM"," AM"),8))
Please go to Format Cells, choose Number -> Custom Format and set desired format
Hi
I am adding 10.8 days to a date, and it is returning as 1/18/2020 4:55:54 AM and I cannot use vlookup again this returned date. How do I format the return date to only date? So I can use as only date format for other formulas. Thank you.
Hello Avarma!
I’m sorry but your task is not entirely clear to me.
For me to be able to help you better, please describe your task in more detail. Please let me know in more detail what you were trying to find, what formula you used and what problem or error occurred. It’ll help me understand it better and find a solution for you. Thank you.
Hellow Ablebits Team,
Have Changed the US date format(mm-dd-yy) to English (U K) (dd-mm-yy).Existing dates have changed successfully But with new entries in dd-mm-yy it does work, however it is OK with
mm-dd-yy entries. What to do to have both entries & display in dd-mm-yy UK format.
Best Regards
Abdul Aziz Khan
Hi,
I am wondering if I have information in mm dd hh:mm:ss yyyy, is it possible to transfer it to yyyy/mm/dd hh:mm:ss.
Anne
Hello!
Please go to Format Cells, choose Number -> Custom Format and set
yyyy/mm/dd hh:mm:ss
I hope this will help, otherwise please do not hesitate to contact me anytime.
Hi Alexander,
I have the same issue as Anne, and change the format using the custom format option.
However, I was wondering if there was any way to make the change as permanent, as every time I open an excel file, I have to change it, and this happens several times a day, so it gets a bit frustrating at times.
Thanks in advance for your help
Hello Tabish!
When you enter a date or time in a cell, it displays in the default date and time format. This default format is based on the regional date and time settings specified in the Windows Control Panel and changes when you configure these settings in the Control Panel. Set the format there. I hope it’ll be helpful.
Hi,
This appears to be a great source of information.
I have a date with a time as :
05/12/2020 23:59
My excel sheet is interpreting as 5 December 2020 23:59 however it is meant to be 12 may 2020 23:59. It is data that is downloaded and both time and date come a single entry in the table I download. is there any way to convert it to be correct. I have now been trying for over 5 hours!!
help is needed please.
Best regards,
David
Hello David!
Check what date format you have installed on Windows. Go to Control Panel – Time – Region Settings – Change data formats
I hope this will help, otherwise please do not hesitate to contact me anytime.
Hi,
Thank you for getting back to me. The problem is that the the website generating the data gas a glitch and is presenting the day and month in reverse. So if it was the 13 May 2020, the cell contains 5/13/2020 but yet the excel sheet thinks it is the 5 of the 13th month which obviously causes problems. They are working ona fix to the site now but i would like to know if there is anything i could do to convert it in the meantime in case they cannot fix the issue.
Hope to hear from you soon,
David
Hello David!
Please try the following formula:
=DATEVALUE(REPLACE(REPLACE(G1,1,2,MID(G1,4,2)),4,2, LEFT(G1,2))) + TIMEVALUE(REPLACE( REPLACE(G1,1,2,MID(G1,4,2)),4,2,LEFT(G1,2)))
Please go to Format Cells, choose Number -> Custom Format and set
dd mmmm yyyy hh:mm:ss
I hope this will help, otherwise please do not hesitate to contact me anytime.
hi
i have problem in my excel sheet in date column. I have calendar period column in which date shows like 201810 in which last 2 digits are month and 1st 4 are year. i want to convert in date format like 10-2018. how to do this please help me with this.
Thank You
Hello Aman!
Please try the following formula:
=DATE(LEFT(A13,4),MID(A13,5,2),1)
Please go to Format Cells, choose Number -> Custom Format and set
mm-yyyy
Or instead of the date in the cell, you can write text and not use custom format:
=TEXT(DATE(LEFT(A13,4),MID(A13,5,2),1),"mm-yyyy")
I hope it’ll be helpful.
Great info, thx! I have the same question about capitals
Hello Sir.
How can we format the date using capital letter in excel for example 31 MAY 2020 instead of 31 May 2020?
Hello Willy!
The date format in Excel does not use capitalization. But you can use the formula
= UPPER(TEXT(A1,"dd mmmm yyyy"))
I hope it’ll be helpful.
Hi Sir, your formula really helpful!!.. Thanks
I need Year-Month-Date how to Possible?
Hello Rabiul!
I hope you have studied the recommendations in the above tutorial. Please let me know in more detail what you were trying to find, what format you used and what problem or error occurred. In that case I will try to help you.
Dear Sir,
In navigation problems we have situation where we have to find the duration between 2 times, e.g 23:00 and 01:25 then unable to do it
Hello Capt.T.I.Paul!
If I understand your task correctly, the following formula should work for you:
=IF(A1 > A2,A2-A1+1,A2-A1)
where A1 is 23:00 and A2 - 01:25
I hope this will help, otherwise please do not hesitate to contact me anytime.