Date and Time
Date and Time
Date and Time
To enter a date in Excel, use the "/" or "-" characters. To enter a time,
use the ":" (colon). You can also enter a date and a time in one cell.
img1
Note: Dates are in US Format. Months first, Days second. This type of
format depends on yourwindows regional settings. Learn more about Date
and Time formats.
img2
Note: use the MONTH and DAY function to get the month and day of a
date.
1
Date Function
img3
2. To add a number of years, months and/or days, use the DATE function.
img4
Note: the DATE function accepts three arguments: year, month and day.
Excel knows that 6 + 2 = 8 = August has 31 days and rolls over to the next
month (23 August + 9 days = 1 September).
To get the current date and time, use the NOW function.
img5
2
Note: use the TODAY function to get the current date only. Use NOW()-
TODAY() to get the current time only (and apply a Time format).
img6
Note: use the MINUTE and SECOND function to return the minute and
second.
Time Function
To add a number of hours, minutes and/or seconds, use the TIME function.
img7
3
2. DateDif
To get the number of days, weeks or years between two dates in Excel,
use the DATEDIF function. The DATEDIF function has three arguments.
1. Fill in "d" for the third argument to get the number of days between two
dates.
img8
2. Fill in "m" for the third argument to get the number of months between
two dates.
img9
3. Fill in "y" for the third argument to get the number of years between two
dates.
4
img10
4. Fill in "yd" for the third argument to ignore years and get the number of
days between two dates.
img11
5. Fill in "md" for the third argument to ignore months and get the number
of days between two dates.
img12
5
6. Fill in "ym" for the third argument to ignore years and get the number of
months between two dates.
img13
img14
img15
6
3. Weekdays
Learn how to get the day of the week of a date in Excel and how to get
the number of weekdays/working days between two dates.
Weekday Function
img16
2. You can also use the TEXT function to display the day of the week.
img17
3. Create a custom date format (dddd) to display the day of the week.
7
img18
Networkdays Function
img19
img20
8
img21
3. Dates are stored as numbers in Excel and count the number of days
since January 0, 1900. Instead of supplying a list, supply an array constant
of the numbers that represent these dates. To achieve this, select E1:E2 in
the formula and press F9.
img22
Workday Function
9
img23
Note: the WORKDAY function returns the serial number of the date. Apply
a Date format to display the date.
img24
Again, if you supply a list of holidays, the WORKDAY function returns the
date before or after a specified number of workdays (weekends and
holidays excluded).
10
4. Days until Birthday
To calculate the number of days until your birthday in Excel, execute the
following steps.
2. Select the cell next to it and enter the TODAY function to return today's
date.
img25
3. The most difficult part in order to get the number of days until your
birthday is to find your next birthday. The formula below does the trick.
img26
Explanation: The DATE function accepts three arguments: year, month and
day. We used the DATEDIF function to find the number of complete years
("y") between Date of Birth and Today. DATEDIF(A2,B2,"y") equals 32. If
32 complete years have passed since your date of birth (in other words,
you have already celebrated your 32st birthday), your next birthday will be
32 + 1 = 33 years after your date of birth.
11
4. Next, we use the DATEDIF function to find the number of days ("d")
between Today and Next Birthday.
img27
1. For example, get the date of the last day of the current month.
img32
Note: the EOMONTH function returns the serial number of the date. Apply
a Date format to display the date.
2. For example, get the date of the last day of the next month.
12
img33
3. For example, get the date of the last day of the current month - 8 months
= 6 - 8 = -2 = October (-2+12=10), 2011!
img34
8. Quarter
An easy formula that returns the quarter for a given date. There's no built-
in function in Excel that can do this.
img39
13
the formula reduces to =ROUNDUP(5/3,0), =ROUNDUP(1.666667,0), 2.
May is in Quarter 2.
img40
Explanation: now it's not difficult to see that the first three values (months)
in column B are rounded up to 1 (Quarter 1), the next three values
(months) in column B are rounded up to 2 (Quarter 2), etc.
img41
14
Explanation: Dates and times are stored as numbers in Excel and count the
number of days since January 0, 1900. June 23, 2012 is the same as
41083. The DATE function accepts three arguments: year, month and day.
DATE(YEAR(A1),1,1) or 1-jan-2012 is the same as 40909. Subtracting
these numbers (41083 - 40909 = 174) and adding 1 gives the day of the
year.
15