This is the final part of our Excel Date Tutorial that offers an overview of all Excel date functions, explains their basic uses and provides lots of formula examples.
Microsoft Excel provides a ton of functions to work with dates and times. Each function performs a simple operation and by combining several functions within one formula you can solve more complex and challenging tasks.
In the previous 12 parts of our Excel dates tutorial, we have studied the main Excel date functions in detail. In this final part, we are going to summarize the gained knowledge and provide links to a variety the formula examples to help you find the function best suited for calculating your dates.
The main function to calculate dates in Excel:
Get current date and time:
Convert dates to / from text:
Retrieve dates in Excel:
Calculate date difference:
Calculate workdays:
Excel DATE function
DATE(year, month, day)
returns a serial number of a date based on the year, month and day values that you specify.
When it comes to working with dates in Excel, DATE is the most essential function to understand. The point is that other Excel date functions not always can recognize dates entered in the text format. So, when performing date calculations in Excel, you'd better supply dates using the DATE function to ensure the correct results.
Here are a few Excel DATE formula examples:
=DATE(2015, 5, 20)
- returns a serial number corresponding to 20-May-2015.
=DATE(YEAR(TODAY()), MONTH(TODAY()), 1)
- returns the first day of the current year and month.
=DATE(2015, 5, 20)-5
- subtracts 5 days from May 20, 2015.
At first sight, the Excel DATE function looks very simple, however, it does have a number of specificities pointed out in the Excel DATE tutorial.
Below you will find a few more examples where the Excel DATE function is part of bigger formulas:
Excel TODAY function
The TODAY()
function returns today's date, exactly as its name suggests.
TODAY is arguably one of the easiest Excel functions to use because it has no arguments at all. Whenever you need to get today's date in Excel, enter the following formula is a cell:
=TODAY()
Apart from this obvious use, the Excel TODAY function can be part of more complex formulas and calculations based on today's date. For example, to add 7 days to the current date, enter the following formula in a cell:
=TODAY()+7
To add 30 weekdays to today's date excluding weekend days, use this one:
=WORKDAY(TODAY(), 30)
Note. The date returned by the TODAY function in Excel updates automatically when your worksheet is recalculated to reflect the current date.
For more formula examples demonstrating the use of the TODAY function in Excel, please check out the following tutorials:
Excel NOW function
NOW()
function returns the current date and time. As well as TODAY, it does not have any arguments. If you wish to display today's date and current time in your worksheet, simply put the following formula in a cell:
=NOW()
Note. As well as TODAY, Excel NOW is a volatile function that refreshes the returned value every time the worksheet is recalculated. Please note, the cell with the NOW() formula does not auto update in real-time, only when the workbook is reopened or the worksheet is recalculated. To force the spreadsheet to recalculate, and consequently get your NOW formula to update its value, press either Shift+F9 to recalculate only the active worksheet or F9 to recalculate all open workbooks.
For more details, please see How to use NOW function in Excel.
Excel DATEVALUE function
DATEVALUE(date_text)
converts a date in the text format to a serial number that represents a date.
The DATEVALUE function understands plenty of date formats as well as references to cells that contain "text dates". DATEVALUE comes in really handy to calculate, filter or sort dates stored as text and convert such "text dates" to the Date format.
A few simple DATEVALUE formula examples follow below:
=DATEVALUE("20-may-2015")
=DATEVALUE("5/20/2015")
=DATEVALUE("may 20, 2015")
And the following examples demonstrate how the DATEVALUE function can help with solving real-life tasks:
Excel TEXT function
In the pure sense, the TEXT function cannot be classified as one of Excel date functions because it can convert any numeric value, not only dates, to a text string.
With the TEXT(value, format_text) function, you can change the dates to text strings in a variety of formats, as demonstrated in the following screenshot.
Note. Though the values returned by the TEXT function may look like usual Excel dates, they are text values in nature and therefore cannot be used in other formulas and calculations.
Here are a few more TEXT formula examples that you may find helpful:
Excel DAY function
DAY(serial_number)
function returns a day of the month as an integer from 1 to 31.
Serial_number is the date corresponding to the day you are trying to get. It can be a cell reference, a date entered by using the DATE function, or returned by other formulas.
Here are a few formula examples:
=DAY(A2)
- returns the day of the month from a date in A2
=DAY(DATE(2015,1,1))
- returns the day of 1-Jan-2015
=DAY(TODAY())
- returns the day of today's date
Excel MONTH function
MONTH(serial_number)
function in Excel returns the month of a specified date as an integer ranging from 1 (January) to 12 (December).
For example:
=MONTH(A2)
- returns the month of a date in cell A2.
=MONTH(TODAY())
- returns the current month.
The MONTH function is rarely used in Excel date formulas on its own. Most often you would utilize it in conjunction with other functions as demonstrated in the following examples:
For the detail explanation of the MONTH function's syntax and plenty more formula examples, please check out the following tutorial: Using the MONTH function in Excel.
Excel YEAR function
YEAR(serial_number)
returns a year corresponding to a given date, as a number from 1900 to 9999.
The Excel YEAR function is very straightforward and you will hardly run into any difficulties when using it in your date calculations:
=YEAR(A2)
- returns the year of a date in cell A2.
=YEAR("20-May-2015")
- returns the year of the specified date.
=YEAR(DATE(2015,5,20))
- a more reliable method to get the year of a given date.
=YEAR(TODAY())
- returns the current year.
For more information about the YEAR function, please see:
Excel EOMONTH function
EOMONTH(start_date, months)
function returns the last day of the month a given number of months from the start date.
Like most of Excel date functions, EOMONTH can operate on dates input as cell references, entered by using the DATE function, or results of other formulas.
A positive value in the months
argument adds the corresponding number of months to the start date, for example:
=EOMONTH(A2, 3)
- returns the last day of the month, 3 months after the date in cell A2.
A negative value in the months argument subtracts the corresponding number of months from the start date:
=EOMONTH(A2, -3)
- returns the last day of the month, 3 months before the date in cell A2.
A zero in the months argument forces the EOMONTH function to return the last day of the start date's month:
=EOMONTH(DATE(2015,4,15), 0)
- returns the last day in April, 2015.
To get the last day of the current month, enter the TODAY function in the start_date argument and 0 in months:
=EOMONTH(TODAY(), 0)
You can find a few more EOMONTH formula examples in the following articles:
Excel WEEKDAY function
WEEKDAY(serial_number,[return_type])
function returns the day of the week corresponding to a date, as a number from 1 (Sunday) to 7 (Saturday).
- Serial_number can be a date, a reference to a cell containing a date, or a date returned by some other Excel function.
- Return_type (optional) - is a number that determines which day of the week shall be considered the first day.
You can find the complete list of available return types in the following tutorial: Day of the week function in Excel.
And here are a few WEEKEND formula examples:
=WEEKDAY(A2)
- returns the day of the week corresponding to a date in cell A2; the 1st day of the week is Sunday (default).
=WEEKDAY(A2, 2)
- returns the day of the week corresponding to a date in cell A2; the week begins on Monday.
=WEEKDAY(TODAY())
- returns a number corresponding to today's day of the week; the week begins on Sunday.
The WEEKDAY function can help you determine which dates in your Excel sheet are working days and which ones are weekend days, and also sort, filter or highlight workdays and weekends:
Excel DATEDIF function
DATEDIF(start_date, end_date, unit)
function is specially designed to calculate the difference between two dates in days, months or years.
Which time interval to use for calculating the date difference depends on the letter you enter in the last argument:
=DATEDIF(A2, TODAY(), "d")
- calculates the number of days between the date in A2 and today's date.
=DATEDIF(A2, A5, "m")
- returns the number of complete months between the dates in A2 and B2.
=DATEDIF(A2, A5, "y")
- returns the number of complete years between the dates in A2 and B2.
These are just the basic applications of the DATEDIF function and it is capable of much more, as demonstrated in the following examples:
Excel WEEKNUM function
WEEKNUM(serial_number, [return_type])
- returns the week number of a specific date as an integer from 1 to 53.
For example, the below formula returns 1 because the week containing January 1 is the first week in the year.
=WEEKNUM("1-Jan-2015")
The following tutorial explains all the specificities on the Excel WEEKNUM function: WEEKNUM function - calculating week number in Excel.
Alternatively you can skip directly to one of the formula examples:
Excel EDATE function
EDATE(start_date, months)
function returns the serial number of the date that is the specified number of months before or after the start date.
For example:
=EDATE(A2, 5)
- adds 5 months to the date in cell A2.
=EDATE(TODAY(), -5)
- subtracts 5 months from today's date.
For a detailed explanation of EDATE formulas illustrated with formula examples, please see: How to use EDATE function in Excel.
Excel YEARFRAC function
YEARFRAC(start_date, end_date, [basis])
function calculates the proportion of the year between 2 dates.
This very specific function can be used to solve practical tasks such as calculating age from date of birth.
Excel WORKDAY function
WORKDAY(start_date, days, [holidays])
function returns a date N workdays before or after the start date. It automatically excludes weekend days from calculations as well as any holidays that you specify.
This function is very helpful for calculating milestones and other important events based on the standard working calendar.
For example, the following formula adds 45 weekdays to the start date in cell A2, ignoring holidays in cells B2:B8:
=WORKDAY(A2, 45, B2:B85)
For the detailed explanation of WORKDAY's syntax and more formula examples, please check out:
Excel WORKDAY.INTL function
WORKDAY.INTL(start_date, days, [weekend], [holidays])
is a more powerful variation of the WORKDAY function introduced in Excel 2010.
WORKDAY.INTL allows calculating a date N number of workdays in the future or in the past with custom weekend parameters.
For example, to get a date 20 workdays after the start date in cell A2, with Monday and Sunday counted as weekend days, you can use either of the following formulas:
=WORKDAY.INTL(A2, 20, 2, 7)
or
=WORKDAY.INTL(A2, 20, "1000001")
Of course, it might be difficult to grasp the essence from this short explanation, but more formula examples illustrated with screenshots will make things really easy:
Excel NETWORKDAYS function
NETWORKDAYS(start_date, end_date, [holidays])
function returns the number of weekdays between two dates that you specify. It automatically excludes weekend days and, optionally, the holidays.
For example, the following formula calculates the number of whole workdays between the start date in A2 and end date in B2, ignoring Saturdays and Sundays and excluding holidays in cells C2:C5:
=NETWORKDAYS(A2, B2, C2:C5)
You can find a comprehensive explanation of the NETWORKDAYS function's arguments illustrated with formula examples and screenshots in the following tutorial:
NETWORKDAYS function - calculating workdays between two dates
Excel NETWORKDAYS.INTL function
NETWORKDAYS.INTL(start_date, end_date, [weekend], [holidays])
is a more powerful modification of the NETWORKDAYS function available in Excel 2010 and later. It also returns the number of weekdays between two dates, but lets you specify which days should be counted as weekends.
Here is a basic NETWORKDAYS formula:
=NETWORKDAYS(A2, B2, 2, C2:C5)
The formula calculates the number of workdays between the date in A2 (start_date) and the date in B2 (end_date), excluding the weekend days Sunday and Monday (number 2 in the weekend parameter), and ignoring holidays in cells C2:C5.
For full details about the NETWORKDAYS.INTL function, please see:
NETWORKDAYS function - counting workdays with custom weekends
Hopefully, this 10K foot view on the Excel date functions has helped you gain the general understanding of how date formulas work in Excel. If you want to learn more, I encourage you to check out the formula examples referenced on this page. I thank you for reading and hope to see you again on our blog next week!
595 comments
hi. I'm trying to set up Conditional Formatting using a Funtion affecting 3 cells (A4, B4, C4) based on a cell's value (C4).
I am trying to use today's date (<=TODAY()) and the presence of a date in this same cell (=NOTBLANK()).
I'm trying to do this in single Function (AND).
is this posssible?
Hi, I've to worksheet in the Excel, one that compiles all my information and another where I insert all the products received. The received products sheet contains all the info from the product received including the expiration date.
I would like that the information for the expiration date will appear in the main sheet, so I used the VLOOKUP. The problem is that most of the times I receive the same product more than once so I will have different expiration dates. How can my main sheet only show the latest expiration date?
Many thanks
How to get current (day) in excel .
i am trying to calculate month and days difference in two days
cell A1 07/07/2016
cell b1 07/10/2016
formula
=ROUNDDOWN((B1-A1)/365,0)&" "&"Year"&" "&TEXT(B1-A1,"mm")&" "&"months"&" "&TEXT(B1-A1,"D")&" "&"Days"
output 0 Year 04 months 1 Days
answer should b 3 month why it is calculating wrong days and month
plz reply
if possible plz let me know can i use text function for year difference also?
Hi, I'm looking the formula for a "date and time of completion". For example.
Start Date and time 13Nov2016 12:30
Cargo onboard 2000 bbls
Rate/hr : 50 bbls/hr
I am trying to make any dates before today's date change into 9/9/999. If the date is today or after, I want it to stay as is. I have been using this function and it does not work.
=IF(U2<TODAY(), "9/9/9999", U2)
Please help. And by the way, when I put data into these cells, it just deletes the formula. This issue seems like an Excel 101 issue I can't find a solution online for. Please help.
Hi Matt,
You cannot have a formula perform a function on itself (the same cell). You have to enter the formula in a different cell and it will perform the function you are attempting to do. So, say the dates you are entering are in column A. If you create column B next to it, and then have the formula you are using refer to the values in column A, you will get the result you are looking for.
Example: Enter 1/15/1995 in cell A1. Then in cell B1 enter =IF(A1<TODAY(), "9/9/9999", A1) . Cell B1 will display the date if it is today or in the future, and will display 9/9/9999 if it is in the past.
Hi,
Could you please advise me.
I have a staff hollidays sheet.
First collumn with the staff name and first row with callendar dates.
Each hollidays days is marked with a h, and with a countif formula is count the total.
What i need is a formula that would work as if would be the countif formula, but counting until the date of today.
Generally speaking would be something as, How many h do we have until the calendar date that we are on.
Kind regards,
Irina Lopes
Please can you help, I need to set up a spread sheet and need to have a column that shows that days date when a Y is put into another cell, can this be done and if so what would the sum be.
Many thanks
I am trying to build a spreadsheet of folks showing EOD dates (Entry on Duty). What I would like the formula to do is change their available leave automatically once they reach their 3 or 15 years of service. In other words, before the 3 years you only accumulate 4 days of leave whereas after 3 years it will go up to 6 days, and 15 yrs. to 8 days.
Is this option possible?
Many thanks in advance.
Hi,
I am working on a database using excel, and trying to get some conditional formatting up and going.
Basically, I would like an entire row to be highlighted if one cell in that row (date format) returns a date within a certain year (or even within the past year).
I've only just begun using conditional formatting, so apologies if this is not the place to ask!
Hi,
I need to get the number of Days (day 2 - day 1 below), starting from today:
day 2: the previos working day (yesterday, or if yesterday was not a working day, the last working day before that).
day 1: the working day before day 2.
If possible with regards to hollidays (which I assum must be in a separate list)
Thnks all, Tomas
Name ID Date
Sagar 123 9/26/2016
Sagar 123 9/27/2016
Sagar 123 9/28/2016
Raghu 234 9/26/2016
Raghu 234 9/27/2016
Raghu 234 9/28/2016
In next column, I need the largest date to be displayed for every person. After displaying the date, 2 cells should be empty and again largest date for 2nd name. Again 2 cells will be empty and largest date for 3rd person. I need result looking like that. Is there any formula?
PLEASE HELP!
I'm trying new ways to use excel and I saw someone have a roster up that automatically changes the day in the column.
How do I achieve this? Do I use a formula or macro?
I'm so confused but amazed at the same time.
Any help would be greatly appreciated :)
Hello,
I have tried using the datedif function in many different ways to calculate the total months difference in between two cells values. It has to include the month it is in, and the month it is ending in (oct 2016). So for example, it shows Paid through, and always ends in Oct 2016. So this would be 9 months. Including Feb, to Oct. If anyone can help in regard to this it would be appreciated!! I keep getting #Name? and #Value errors.
Paid Through October 2016 Total Months Difference
1-Feb-16 1-Oct-16 #NAME?
2017-03 2016-10 #VALUE!
2017-02
2016-10
2016-10
2016-09
Need any help you can provide for following situation.
I'm maintaining a yearly Excel spreadsheet for 1 Dec - 31 Oct to account for a variety of activities. Trying to provide Quarterly and Annual summaries has required yearly change of 95 comparison functions since I don't understand how to compare 1-Dec-2015 through 28-Feb-2016 without first determining the data equivalent of each date, e.g., 42339 and 42428 respectively. Solution has been (for 1st Quarter):
=SUMIFS(Contacts!$K$3:$K$5002,Contacts!$D$3:$D$5002,">=42339",Contacts!$D$3:$D$5002,"<=42428")
How can I just compare each transaction with a 1-Dec-2015 and a 28-Feb-2016? Or more sustainable comparison. And, once accomplished, annual update of spreadsheet would allow blanket change of applicable respective year(s) instead of having to change all 95 individually. Would greatly appreciate your assistance.
Larry
I would like to know that can excel calculate and show the date of Friday before that day or not.
For example,
A B
Customer required shipment date 11-Jan-2017
Shipment Date that we need to ship 21-Nov-2016 (I use formula B1-51)
However, The loading date of the shipment needs to be on Friday. So, we would like to know the
formula that can calculate the Friday date before 21-Nov-2016 which is 18-Nov-2016.
Please kindly advice whether it have the formula to calculate this kind of problem or not.
i want a formulation in excel
design target design to costing send date costing target
05-04-2016 07-04-2016 09-04-2016
if first dept. not able to achieve there target date then next department will allocate delays no of days as per design to costing send date
Hi,
I want date of every Monday of every month when Monday came, date can be changed automatically. Please Help.
I have a spreadsheet that needs to have a date highlighted (column A) if it exceeds the 48 hour due date (column C -hidden and auto calculated) IF a completion date is not located in Column D. I would also need the highlight reverted once a completion date is added to column D. any thoughts? This spreadsheet has blank, formatted rows below for when additional items are added. Any ideas? Thank you!!
This is what I have currently, but nothing is changing, and many items should be highlighted RED now...
="IF($C>=TODAY),($D=ISBLANK)"
I have 2 columns target date e.g Dec-16 and Actual date e.g Dec- 16, what I need is to create RAG status in a 3rd column
So if column g is equal to column h gives me An A
if column g is less than column H gives me a G
if column g is greater than column H gives me a R
so if I could ask for assistance on a formula as going round in circles trying IF etc