Date with my sheet – 10 tips on using date / time in excel
Excel date time features are very handy and knowing them a little in depth can help you save a ton of time in your day to day spreadsheet chores. Let us prepare for your date with the sheet using these 10 handy tips.
Before jumping on to the tips, it helps to know how excel represents the date and time.
Microsoft Excel stores dates as sequential numbers … By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,448 days after January 1, 1900. Excel stores times as decimal fractions because time is considered a portion of a day. [Excel Help Text on Date / Time]
So you see, Date and Time are in fact numbers in Excel. Just enter a date in your excel sheet and format it as number to see its equivalent numeric value. Today is 25Aug2008
and excel represents it as 39685
.
Now that you know the little secret behind date / time, lets move to the 10 tips.
1. Test whether a date is future or past
You can find whether a date is past or future or today using simple if formula like: =if(this_date=today(),"Today",if(this_date < today(),"Past","Future"))
today()
is the spreadsheet function using which you can find today's date.
2. Find the number of days between two dates
Since dates are represented as sequential numbers in excel, in order to find out how many days are between any given 2 dates, just subtract one from another. For eg. you can use =today()datevalue("08/15/1947")
to find that it is 22,291 days since India's independence (August 15, 1947).
3. Formatting dates
Having date / time in the sheet is not enough if you can not make it look like the way you want. For eg. you may want to show date as "Monday  August 25, 2008". You can use cell formatting to do this. Just select the cell with date and hit ctrl+1 and in the "Number" tab select "Custom" as category and mention "dddd mmm dd, yyy" as format string.
Try these other date formats as well. Learn more about custom cell formatting.
4. Autofilling only weekdays
We all know that in order to fill a series of dates in excel sheet, you just need to enter first few dates and then select the range and drag to auto fill the selection with rest of the dates. But what if you need to fill only weekdays?
You can do that easily with Auto fill option  "weekdays only" as shown on the right. learn more.
5. Find out the day of week from a given date
Finding whether a day is weekend or weekday is useful if you are making project plans or resource allocation sheets. You can do this by simply using weekday()
function. For eg. =weekday("08/25/2008")
would return 2 (Excel, by default starts the week at Sunday, hence Monday is indicated as 2).
If you would like to start the week with Monday like most of us do, use =weekday("08/25/2008",2)
.
6. Highlight weekends using conditional formatting
Often when you are making project plans or reports, it helps if the weekends or after office hours can be grayed out. You can do this easily with conditional formatting as shown below:
In order to do this, we can test whether a given a day is weekend or not in conditional formatting by =WEEKDAY(this_date,2)>5
as weekday() returns 6 and 7 for Saturday and Sunday.
You can use similar logic to highlight after office hours (before 9AM or after 5PM) for time values. Learn these 5 tips to master conditional formatting.
7. Adding / Subtracting dates
Since Excel dates are nothing but numbers, you can find out the difference between two given dates by just subtracting one from another. For eg. ="09/20/2008""08/25/2008"
will return 26
In order to add n number of days to a given date, you can just add that number to given date. For eg. ="08/25/2008"+26
will return 09/20/2008
8. Ensuring a valid date or time is entered in a cell
When sharing your sheets with others to enter some data, it may be useful if you can restrict them to enter only valid date values in cells that require date value. You can do that using cell data validation feature in excel. Just select the cell to which you want to apply date / time validation, goto menu > data > validation and set type as "Date" or "Time" and specify criteria.
For example, you can specify criteria like the one on left to ensure that date entered is at least 18 years before 1/1/2008. What more, using message option of data validation settings you can even show messages like this:
9. Insert today's date, current time using key board shortcuts
Just go to the cell where you want to insert date and press ctrl+;
To get current time, use ctrl+shift+; ( thus ctrl+: )
Btw, if you are planning to get today's date or current time using formulas, you can use today() and now(). Also learn these 11 very useful excel keyboard shortcuts.
10. Filling every 2nd / 3rd day
Often when you are entering dates in to the spreadsheet, it may be required to just enter every second or third day only. You can do this by changing the step value of autofill criteria (the default step value is 1).
 Enter the start date in first cell.
 Select a range of cells in which you would like to fill rest of cells.
 Go to Menu > Edit > Fill > Series
 In the dialog, mention step criteria as 2 or 3 as shown aside.
That is all, with these 10 tips I hope I made your date with that spreadsheet is made little exciting.
Like this? Also read Master copy  paste with these 17 paste tricks, 6 things you dont know about excel if() functions, 15 fun things you can do with excel
 
 

Leave a Reply
Quickly process text using split() spreadsheet function in google docs  Excel links of the week – weekend without wire [Aug 26] 
49 Responses to “Date with my sheet – 10 tips on using date / time in excel”
[...] Date with my sheet – 10 tips on using date / time in excel (tags: excel totw) Posted in Uncategorized  [...]
[...] 10 Tips on using Date / Time in Excel [...]
[...] More on date / time: 10 tips on using, formatting date / time in excel. [...]
Hi Chandoo,
Since this article was for Dates, below are 2 easy ones to calculate the Start and End of Month. (without using the EOMONTH formula as available in Analysis Toolpak).
In Cell A1, put any date
then in the cell where you would want the Start of Month put the below formula
1. Start of the Month
=DATE(YEAR(A1),MONTH(A1),1)
2. End of Month
=DATE(YEAR(A1),MONTH(A1)+1,0)
Hope this would help a lot who were dependant of EOMONTH..
cheers
~Vijay
@Vijay: That is an awesome tip. Thank you so much for sharing it with all of us.
Perfect
I run a trolley tour business and need to set up a data base to track tickets sold by mutable vendors (from store, on the street ,etc)and by class ( adult, senior,child and discounts ) can you help or direct me to one that could?
I know how to write macro’s for excel, but I have 1 issue that I cant figure out and would appreciate some help.
I want to key a range of dates, (7/1/097/12/09) then write a macro to go find the info for that range and bring it back to my spread sheet.
Thanks for any help….
@Glenn: you can try a user defined function if the information you want to gather can be derived only from the 2 dates entered. You can write a macro, if you need to refer to other ranges in the workbook to gather the info based on the dates entered. I am not sure what you meant by “go find the info for that range”. May be if you tell what you are trying to find, I can suggest the approach for writing a macro…
[...] Important excel formulas: IF and Then, Vlookup, Offset, Sumif, Countif, Working with date and time [...]
[...] Tips on using date & time in excel, List of excel date & time formulas, More excel quick tips [...]
talking about dates, therz a formula that i use very frequently to calculate the difference between two dates.
its not documented in 2007 though
=DATEDIF(START_DATE,END_DATE,”Y”) – gives you the years
=DATEDIF(START_DATE,END_DATE,”YM”) – remaining months
=DATEDIF(START_DATE,END_DATE,”MD”) – remaining days
im sure you’ll know this. wonder why it isnt documented. works fine with 2003 and 2007
[...] free downloads  working with date and time in excel tweetmeme_source = 'r1c1'; tweetmeme_style = [...]
[...] Working with Dates & Times in Excel – 10 tips [...]
Help please… I have two dates eg: 1/8/10 – 10/8/10 and i would like to know the number of Fridays and Mondays in any given period
Ray
Try the following user defined function:
===
Function NoMonFri(uStart As Range, uEnd As Range, Optional uType As Integer) As Double
Count = 0
For i = uStart To uEnd Step 1
If Weekday(i) = 2 Or Weekday(i) = 6 Then Count = Count + 1
Next i
If uType = 1 Then
If Weekday(uStart) = 2 Or Weekday(uStart) = 6 Then Count = Count – 1
If Weekday(uEnd) = 2 Or Weekday(uEnd) = 6 Then Count = Count – 1
End If
NoMonFri = Count
End Function
====
Copy the above into a Code Module
To use just enter
=NoMonFri(A1, A2) or
=NoMonFri(A1, A2,1)
Where A1 & A2 are the Start and End Dates (inclusively)
The use of the optional 1 will Exclude the Start and End dates
@Ray… You can also do this using SUMPRODUCT (ahem)
Assuming first date is in C6 and second date is in C7,
=SUMPRODUCT(–(MOD(WEEKDAY(ROW(INDIRECT(C6&”:”&C7)),2),4)=1))
Will give you the number of Mondays and Fridays between C6 and C7 (including both days)
Also, checkout NETWORKINGDAYS() UDF for more complicated counting… http://chandoo.org/wp/2009/06/09/networkingdays/
[...] Process your data: Assuming your data looks like what I shown to left, just use simple formulas to make it look like the table to right. [related: how to work with dates & times in excel] [...]
very useful tip, thanks alot
Hello Chandoo,
How to convert no into time. for ex: 3600(In Seconds) into 1:00:00
Thanks,
Chandra Shekar B
@Chandra
Times are a fraction of 1
So 6am is 0.25
12 noon is 0.5
6pm is 0.75
So convert hrs and mins to a fraction of 24 hrs
1 Hr = 1/24
3600 seconds = 3600/(24*3600)
etc
Hello Hui,
Thanks a lot
Hello,
I cant get Point 6 above to work (highlighting weekends).
Is there an actual example I can see in action anywhere?
Otherwise a very helpful and informative website.
Regards,
Patrick
Hi Chandoo,
When discussing about time.. I have one question too. Basically, I have one sheet in which we enter “Shift IN” & “Shift OUT” times as “hh:mm” format in A and B columns and next columns C & D pulls the scheduled and present count of agents from other sheet by VLOOKUPing times as
IN time (hh:mm) – OUT Time (hh:mm). For eg; 03:30 – 12:30
Columns A and B have been validated to accept only values between 00:00~23:30 (half hour intervals). and when pasting data, the values are usually accepted and I don’t get any errors of validation.
But, when performing vlookup to get the number of scheduled agents say as of the time interval 03:30, I get an #N/A error. I have confirmed ranges are all fine, but what I found is that the time although shows same but they are actually of different days. Say for eg;
41023.39583 gives 9:30
41024.39583 gives 9:30 too..
Validation is accepted as time is same, and it works fine if I select the time interval from the validation list. So, was wondering, if I can select the same interval from the list using VBA.. so that whatever the time intervals gets updated, I just need to run a macro to automatically select the interval from the validation list.. I have come across that we can use Cell.Validation.Formula1 in some manner to get the item from list.. but it would take the number of the item in the list.. wondered if I could get the item through text. Any ideas to accomplish this task?
Regards,
Avinash
hi,
can you help me in, i just want to know how will i get the corresponding DAY when i entered a specific DATE?
Thanks,
Sheila
hi,
sir can u help me,
how to set a validity period & date of time in microsoft excel.
eg: suppose i m using a file sheet and setting a date of 01.04.2012, time 12.00am & wan’t dat the sheet should stop working in 1 month date & time ( 30.04.2012 ).
eg : suppose we are going internet cafe dere we are taking a browsing of 1hour time, as we r close 2 our time d browsing stop working.
in dis way i wan’t sheet to be set by date & time.
so pls help me how to do.
thanks,
navin.
Hi,
Sir ur article is very helpful….Thnaks for that but i need ur help in this one. i have a monthly report workbook and the sheets are saved by date of that month. I have two cells FromDate and ToDate through which opening and closing stock is calculated(using =SUM(’01092012:25092012′!D7)+ SUM(’26092012:30092012′!D8)) …..Please give me a formula when i will enter any date in ToDate or FromDate cell it will automatically change the other cells formula so to give me sum.
please help me
thanks
Suyash
Hi Mr. Chandoo,
I have 1 question. I have 1 pivot table, successfully done with your guidelines, but how to set Sunday as the start week? means the start day is Sunday, and the end day of the week is Saturday.
TQ in advance.
can someone please tell me that if i want the date of the month to appear on each sheet of my workbook how do i do it by itself? i mean the workbook is of meeting room bookings… so i want to print out sheets date wise for a whole year/
[...] So the formula for end time cell is =starttime + durationminutes / 24 / 60. Note: We need to divide by 24 & 60 because in Excel each day 1 number, each hour is 1/24th and each minute is 1/24/60th. [learn more about Excel dates] [...]
dear friends, please help me to calculate actual time within the range while actual time more or less of range?
TIME IN
TIME OUT
ACTUAL HRS
ACUTAL HRS WITHIN RANGE (7:30:00 to 18:00:00)
7:15:00
18:15:00
11:00:00
?
7:45:00
17:00:00
9:15:00
?
@Niyas
You may want to start having a read of: http://chandoo.org/wp/2010/06/01/dateoverlapformulas/
[...] INTEREST Date with my sheet – 10 tips on using date / time in excel http://chandoo.org/wp/2008/07/29/excelkeyboardshortcuts/ [...]
If I have dates in Indian format ddmmyyyy, excel is not recognizing the same and instead treating the same as mmddyyyy so a date mentioned in Indian system as 09/06/2013 is being treated as 6Sep2013 whereas it actually represents 9Jun2013.
Can I convert these dates in Indian format to corrected ddmmmyyyy system?
Chandoo,
Please i need an advise ASAP i have been using this statement and it cant help
if(and(c1>=a1:a144,c1<=b1:b144),"yes","no"))
and it just works for the first 2 values c1, c2 and doesn't fit for the others.
the case is i have more than one event at the same video and i need to confirm that no event was taken unless it is between start and end.
here are some samples:
Start dtime End Dtime Event Dtime
16/09/2013 22:13:34 16/09/2013 22:14:18 16/09/2013 22:13:38
16/09/2013 22:15:57 16/09/2013 22:24:30 16/09/2013 22:16:02
16/09/2013 22:24:30 16/09/2013 22:33:49 16/09/2013 22:17:32
16/09/2013 22:33:53 16/09/2013 22:35:05 16/09/2013 22:19:02
16/09/2013 22:35:05 16/09/2013 22:39:57 16/09/2013 22:20:02
So as you can see there are more than one event between one start and end dtimes
thanks guys
[…] Using Date & Time in Excel […]
[…] Using Date & Time in Excel […]
Hi Chandoo,
I have an activity tracking sheet, in which column A has activity A, B, C, D & E and column B has start date, column C has start time, column D has end date & column E has end time. Now what i am trying to do is that suppose activity A starts on 31Mar 9:00 AM and finishes an 4Apr 5:00 PM and Activity B starts only after A completes, but if suppose Activity A is delayed by say 1 hour, then activity B, C, D & E which are all dependent on each other will also be delayed by 1 hour, i want to create a template in excel, could you please help?
thanks
Chandresh
[…] Day 32 Date and time arithmetic  The symbols / and – need to be used when inputting dates and Excel has the capability to add dates and times together too. Follow the Excel Easy article here on how http://www.exceleasy.com/functions/datetimefunctions.html Chandoo also has some Top 10 tips too http://chandoo.org/wp/2008/08/26/datetimetipsmsexcel/ […]
Hi,
What will b the formula to get the date more than 3 yrs from the present date ?
Example : today is 16052014 (DMY) then three yrs later what will be the date.
Hi,
What will b the formula to get the date more than 3 yrs from the present date ?
Example : today is 16052014 (DMY) then three yrs later what will be the date.
@Roken
I would use: =EDATE(A1,36)
Where A1 has your date
or
=EDATE(“16/5/2014″,36)
or
=EDATE(Today(),36)
hi..i want to restrict excel from counting non working time…. so i can prepare end dates for a PROJECT if i have total working hours required for my project..
thank for reply if any….
Hi,
Good Morning,
Please use the formula for the below mentioned format in excel.
Formula : =TEXT(H3,”ddmmmmyyyy”).
Format : 17September2014
I’m an evaluator and i evaluate about 20 people everymonth between 610 times each depending on their performance. i track my work in excel by adding the dates i did each peorson. The only rule that i have its that i cant evaluate a person back to back so i have to wait at least one day in between each evaluation. is there a formula where excel would not allow me to enter a date if its one day after the date of the cell to the left?
@Andres
To add one day to a an existing date
=Date + 1
=A10+1
Could anyone please help me. I have not been able to find a format that I need. I need to subtract a value everyday. Example. If I have 365 dollars and I would like Excell to subtract 1 dollar everyday for a year I would have 0 dollars left at the end. Or even 7 dollars a week would work for me. Could anyone please help me on this formula. Thanks
@Jayson
If you have the value 365 in cell A2
In A3 enter: =A21
Then copy A3 down 364 cells
Is there a simple way (no function) to define a formula in a cell like =F(22/08/2014) ?
Currently, i put the date 22/08/2014 in a cell eg. B2 and do my formula a =F(B2).
Thanks