Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Excel 2010 Excel 2007 Excel for Mac 2011 Excel Starter 2010 More…Less
To get detailed information about a function, click its name in the first column.
Note: Version markers indicate the version of Excel a function was introduced. These functions aren’t available in earlier versions. For example, a version marker of 2013 indicates that this function is available in Excel 2013 and all later versions.
Function |
Description |
DATE function |
Returns the serial number of a particular date |
DATEDIF function |
Calculates the number of days, months, or years between two dates. This function is useful in formulas where you need to calculate an age. |
DATEVALUE function |
Converts a date in the form of text to a serial number |
DAY function |
Converts a serial number to a day of the month |
DAYS function |
Returns the number of days between two dates |
DAYS360 function |
Calculates the number of days between two dates based on a 360-day year |
EDATE function |
Returns the serial number of the date that is the indicated number of months before or after the start date |
EOMONTH function |
Returns the serial number of the last day of the month before or after a specified number of months |
HOUR function |
Converts a serial number to an hour |
ISOWEEKNUM function |
Returns the number of the ISO week number of the year for a given date |
MINUTE function |
Converts a serial number to a minute |
MONTH function |
Converts a serial number to a month |
NETWORKDAYS function |
Returns the number of whole workdays between two dates |
NETWORKDAYS.INTL function |
Returns the number of whole workdays between two dates using parameters to indicate which and how many days are weekend days |
NOW function |
Returns the serial number of the current date and time |
SECOND function |
Converts a serial number to a second |
TIME function |
Returns the serial number of a particular time |
TIMEVALUE function |
Converts a time in the form of text to a serial number |
TODAY function |
Returns the serial number of today’s date |
WEEKDAY function |
Converts a serial number to a day of the week |
WEEKNUM function |
Converts a serial number to a number representing where the week falls numerically with a year |
WORKDAY function |
Returns the serial number of the date before or after a specified number of workdays |
WORKDAY.INTL function |
Returns the serial number of the date before or after a specified number of workdays using parameters to indicate which and how many days are weekend days |
YEAR function |
Converts a serial number to a year |
YEARFRAC function |
Returns the year fraction representing the number of whole days between start_date and end_date |
Important: The calculated results of formulas and some Excel worksheet functions may differ slightly between a Windows PC using x86 or x86-64 architecture and a Windows RT PC using ARM architecture. Learn more about the differences.
Need more help?
For work with dates in Excel, in the category «Date and time» is defined in the functions section. Let`s consider the most prevalent functions in this category.
How Excel Processes Time
The Excel program «perceives» the date and time as an ordinary number. The spreadsheet converts to such number, equating the day to unity. As a result, the time value represents a fraction of unity. For example, 12. 00 — is 0. 5.
The date value to the spreadsheet converts to a number which equal to the number of days from January 1, 1900 (so the developers decided) to the specified date. For example, when converting the date 13. 04. 1987, the number is 31880. That is, from 1. 01. 1900 passed 31. 880 days.
This principle underlies in the basis of the calculations of the time data. To find the number of days between two dates, it`s enough to take an earlier period from a later time one.
The example of DATE function
You need to describe of the date value with compiling it with individual elements of numbers.
There is the syntax: year; month, day.
All arguments are required. They can be specified by numbers or by reference to cells with the corresponding numeric data: for the year — from 1900 to 9999; for the month — from 1 to 12; for the day — from 1 to 31.
If you point a larger number for the «Day» argument (than the number of days in the pointed month), you receive the extra days, will be passed to the next month. For example, specifying 32 days for December, we will receive as a result on January 1.
The example of using the function:
Let’s set more days for June:
Examples of using the cell references as arguments:
The DATEDIF function in Excel
It returns the difference between two dates.
The arguments:
- start date;
- final date;
- the code indicating to the units of counting (days, months, years, etc.).
The methods of measuring intervals between the given dates:
- to display the result in days — «d»;
- in months – «m»;
- in years – «y»;
- in months without years – «ym»;
- in days without months and years – «md»;
- in days without years – «yd».
In some versions of Excel, if you use the last two arguments («md», «yd»), the function may give an error. It is better to use to alternative formulas.
The examples of the operation the DATEDIF function:
In Excel 2007 version, this function is not in the directory, but it works. But you need to check the results are better, because there are flaws possible.
The YEAR function in Excel
It returns the year as an integer number (from 1900 to 9999), what corresponds to the specified date. There is only one argument must be entered in the structure of the function – is the date in a numerical format. The argument must be entered using the DATE function or represents to the result of evaluating other formulas.
The example of using the YEAR function:
The MONTH function in Excel: the example
It returns the month as an integer number (from 1 to 12) for a date is specified in a numeric format. The argument – is the date of the month that you want to show in a numerical format. The dates in the text format this function does not handle correctly.
The examples of using the MONTH function:
The examples of DAY, WEEKDAY and functions WEEKNUM in Excel
It returns the day as an integer number (from 1 to 31) for a date specified in a numeric format. The argument – it is the date of the day you want to find in a numerical format.
For returning of the weekday ordinal of the specified date, you can apply the function WEEKDAY:
By default, the function considers Sunday the 1-st day of the week.
To display of the ordinal number of the week for the pointed date, you should use the WEEKNUM function:
The date of 24. 05. 2015 is 22 week in a year. The week starts on Sunday (by default).
As the second argument the figure 2 is specified. Therefore, the formula considers that the week starts on Monday (the 2-d day of the week).
Download all examples functions for working with dates
For indicating of the current date, the function TODAY (no arguments) is used. To display the current time and date, the function NOW() is used.
50+ date and time functions familiar to users coming from an Excel Background.
The main benefits are:
-
Integration of the amazing
lubridate
package for handling dates and times -
Integration of Holidays from
timeDate
and Business Calendars -
New Date Math and Date Sequence Functions that factor in Business Calendars (e.g.
EOMONTH()
,NET_WORKDAYS()
)
These functions are designed to help users coming from an Excel background.
Most functions replicate the behavior of Excel:
-
Names in most cases match Excel function names
-
Functionality replicates Excel
-
By default, missing values are ignored (same as in Excel)
Usage
AS_DATE(x, ...)
AS_DATETIME(x, ...)
DATE(year, month, day)
DATEVALUE(x, ...)
YMD(x, ...)
MDY(x, ...)
DMY(x, ...)
YMD_HMS(x, ...)
MDY_HMS(x, ...)
DMY_HMS(x, ...)
YMD_HM(x, ...)
MDY_HM(x, ...)
DMY_HM(x, ...)
YMD_H(x, ...)
MDY_H(x, ...)
DMY_H(x, ...)
WEEKDAY(x, ..., label = FALSE, abbr = TRUE)
WDAY(x, ..., label = FALSE, abbr = TRUE)
DOW(x, ..., label = FALSE, abbr = TRUE)
MONTHDAY(x, ...)
MDAY(x, ...)
DOM(x, ...)
QUARTERDAY(x, ...)
QDAY(x, ...)
DAY(x, ...)
WEEKNUM(x, ...)
WEEK(x, ...)
WEEKNUM_ISO(x, ...)
MONTH(x, ..., label = FALSE, abbr = TRUE)
QUARTER(x, ..., include_year = FALSE, fiscal_start = 1)
YEAR(x, ...)
YEAR_ISO(x, ...)
DATE_TO_NUMERIC(x, ...)
DATE_TO_DECIMAL(x, ...)
SECOND(x, ...)
MINUTE(x, ...)
HOUR(x, ...)
NOW(...)
TODAY(...)
EOMONTH(start_date, months = 0)
EDATE(start_date, months = 0)
NET_WORKDAYS(start_date, end_date, remove_weekends = TRUE, holidays = NULL)
COUNT_DAYS(start_date, end_date)
YEARFRAC(start_date, end_date)
DATE_SEQUENCE(start_date, end_date, by = "day")
WORKDAY_SEQUENCE(start_date, end_date, remove_weekends = TRUE, holidays = NULL)
HOLIDAY_SEQUENCE(
start_date,
end_date,
calendar = c("NYSE", "LONDON", "NERC", "TSX", "ZURICH")
)
HOLIDAY_TABLE(years, pattern = ".")
FLOOR_DATE(x, ..., by = "day")
FLOOR_DAY(x, ...)
FLOOR_WEEK(x, ...)
FLOOR_MONTH(x, ...)
FLOOR_QUARTER(x, ...)
FLOOR_YEAR(x, ...)
CEILING_DATE(x, ..., by = "day")
CEILING_DAY(x, ...)
CEILING_WEEK(x, ...)
CEILING_MONTH(x, ...)
CEILING_QUARTER(x, ...)
CEILING_YEAR(x, ...)
ROUND_DATE(x, ..., by = "day")
ROUND_DAY(x, ...)
ROUND_WEEK(x, ...)
ROUND_MONTH(x, ...)
ROUND_QUARTER(x, ...)
ROUND_YEAR(x, ...)
Arguments
- x
-
A vector of date or date-time objects
- …
-
Parameters passed to underlying
lubridate
functions. - year
-
Used in
DATE()
- month
-
Used in
DATE()
- day
-
Used in
DATE()
- label
-
A logical used for
MONTH()
andWEEKDAY()
Date Extractors to decide whether or not to return names
(as ordered factors) or numeric values. - abbr
-
A logical used for
MONTH()
andWEEKDAY()
. Iflabel = TRUE
, used to determine if
full names (e.g. Wednesday) or abbreviated names (e.g. Wed) should be returned. - include_year
-
A logicial value used in
QUARTER()
. Determines whether or not to return 2020 Q3 as3
or2020.3
. - fiscal_start
-
A numeric value used in
QUARTER()
. Determines the fiscal-year starting quarter. - start_date
-
Used in Date Math and Date Sequence operations. The starting date in the calculation.
- months
-
Used to offset months in
EOMONTH()
ANDEDATE()
Date Math calculations - end_date
-
Used in Date Math and Date Sequence operations. The ending date in the calculation.
- remove_weekends
-
A logical value used in Date Sequence and Date Math calculations.
Indicates whether or not weekends should be removed from the calculation. - holidays
-
A vector of dates corresponding to holidays that should be removed from the calculation.
- by
-
Used to determine the gap in Date Sequence calculations and value to round to in Date Collapsing operations.
Acceptable values are: A character string, containing one of"day"
,"week"
,"month"
,"quarter"
or"year"
. - calendar
-
The calendar to be used in Date Sequence calculations for Holidays from the
timeDate
package.
Acceptable values are:"NYSE"
,"LONDON"
,"NERC"
,"TSX"
,"ZURICH"
- years
-
A numeric vector of years to return Holidays for in
HOLIDAY_TABLE()
- pattern
-
Used to filter Holidays (e.g.
pattern = "Easter"
). A «regular expression» filtering pattern.
Value
-
Converters — Date or date-time object the length of x
-
Extractors — Returns information from a time-stamp.
-
Current Time — Returns the current date/date-time based on your locale.
-
Date Math — Numeric values or Date Values depending on the calculation.
-
Date Sequences — Return a vector of dates or a Holiday Table (
tibble
). -
Date Collapsers — Date or date-time object the length of x
Details
Converters — Make date and date-time from text (character data)
-
General String-to-Date Conversion:
AS_DATE()
,AS_DATETIME()
-
Format-Specific String-to-Date Conversion:
YMD()
(YYYY-MM-DD),MDY()
(MM-DD-YYYY),DMY()
(DD-MM-YYYY) -
Hour-Minute-Second Conversion:
YMD_HMS()
,YMD_HM()
, and friends.
Extractors — Returns information from a time-stamp.
-
Extractors:
SECOND()
,MINUTE()
,HOUR()
,DAY()
,WEEK()
,MONTH()
,QUARTER()
,YEAR()
Current Time — Returns the current date/date-time based on your locale.
-
NOW()
,TODAY()
Date Math — Perform popular Excel date calculations
-
EOMONTH()
— End of Month -
NET_WORKDAYS()
,COUNT_DAYS()
— Return number of days between 2 dates factoring in working days and holidays -
YEARFRAC()
— Return the fractional period of the year that has been completed between 2 dates.
Date Sequences — Return a vector of dates or a Holiday Table (tibble
).
-
DATE_SEQUENCE()
,WORKDAY_SEQUENCE()
, HOLIDAY_SEQUENCE — Return a sequence of dates between 2 dates that
factor in workdays andtimeDate
holiday calendars for popular business calendars including NYSE and London stock exchange.
Date Collapsers — Collapse a date sequence (useful in dplyr::group_by()
and pivot_table()
)
-
FLOOR_DATE()
,FLOOR_DAY()
,FLOOR_WEEK()
,FLOOR_MONTH()
,FLOOR_QUARTER()
,FLOOR_YEAR()
-
Similar functions exist for CEILING and ROUND. These are wrappers for
lubridate
functions.
Examples
# Libraries
library(tidyquant)
library(tidyverse)
#> ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
#> ✔ forcats 1.0.0 ✔ stringr 1.5.0
#> ✔ purrr 1.0.1 ✔ tibble 3.2.1
#> ✔ readr 2.1.4 ✔ tidyr 1.3.0
#> ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
#> ✖ dplyr::filter() masks stats::filter()
#> ✖ dplyr::first() masks xts::first()
#> ✖ dplyr::lag() masks stats::lag()
#> ✖ dplyr::last() masks xts::last()
#> ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(lubridate)
# --- Basic Usage ----
# Converters ---
AS_DATE("2011 Jan-01") # General
#> [1] "2011-01-01"
YMD("2011 Jan-01") # Year, Month-Day Format
#> [1] "2011-01-01"
MDY("01-02-20") # Month-Day, Year Format (January 2nd, 2020)
#> [1] "2020-01-02"
DMY("01-02-20") # Day-Month, Year Format (February 1st, 2020)
#> [1] "2020-02-01"
# Extractors ---
WEEKDAY("2020-01-01") # Labelled Day
#> [1] 4
WEEKDAY("2020-01-01", label = FALSE) # Numeric Day
#> [1] 4
WEEKDAY("2020-01-01", label = FALSE, week_start = 1) # Start at 1 (Monday) vs 7 (Sunday)
#> [1] 3
MONTH("2020-01-01")
#> [1] 1
QUARTER("2020-01-01")
#> [1] 1
YEAR("2020-01-01")
#> [1] 2020
# Current Date-Time ---
NOW()
#> [1] "2023-03-31 16:08:38 UTC"
TODAY()
#> [1] "2023-03-31"
# Date Math ---
EOMONTH("2020-01-01")
#> [1] "2020-01-31"
EOMONTH("2020-01-01", months = 1)
#> [1] "2020-02-29"
NET_WORKDAYS("2020-01-01", "2020-07-01") # 131 Skipping Weekends
#> [1] 131
NET_WORKDAYS("2020-01-01", "2020-07-01",
holidays = HOLIDAY_SEQUENCE("2020-01-01", "2020-07-01",
calendar = "NYSE")) # 126 Skipping 5 NYSE Holidays
#> [1] 126
# Date Sequences ---
DATE_SEQUENCE("2020-01-01", "2020-07-01")
#> [1] "2020-01-01" "2020-01-02" "2020-01-03" "2020-01-04" "2020-01-05"
#> [6] "2020-01-06" "2020-01-07" "2020-01-08" "2020-01-09" "2020-01-10"
#> [11] "2020-01-11" "2020-01-12" "2020-01-13" "2020-01-14" "2020-01-15"
#> [16] "2020-01-16" "2020-01-17" "2020-01-18" "2020-01-19" "2020-01-20"
#> [21] "2020-01-21" "2020-01-22" "2020-01-23" "2020-01-24" "2020-01-25"
#> [26] "2020-01-26" "2020-01-27" "2020-01-28" "2020-01-29" "2020-01-30"
#> [31] "2020-01-31" "2020-02-01" "2020-02-02" "2020-02-03" "2020-02-04"
#> [36] "2020-02-05" "2020-02-06" "2020-02-07" "2020-02-08" "2020-02-09"
#> [41] "2020-02-10" "2020-02-11" "2020-02-12" "2020-02-13" "2020-02-14"
#> [46] "2020-02-15" "2020-02-16" "2020-02-17" "2020-02-18" "2020-02-19"
#> [51] "2020-02-20" "2020-02-21" "2020-02-22" "2020-02-23" "2020-02-24"
#> [56] "2020-02-25" "2020-02-26" "2020-02-27" "2020-02-28" "2020-02-29"
#> [61] "2020-03-01" "2020-03-02" "2020-03-03" "2020-03-04" "2020-03-05"
#> [66] "2020-03-06" "2020-03-07" "2020-03-08" "2020-03-09" "2020-03-10"
#> [71] "2020-03-11" "2020-03-12" "2020-03-13" "2020-03-14" "2020-03-15"
#> [76] "2020-03-16" "2020-03-17" "2020-03-18" "2020-03-19" "2020-03-20"
#> [81] "2020-03-21" "2020-03-22" "2020-03-23" "2020-03-24" "2020-03-25"
#> [86] "2020-03-26" "2020-03-27" "2020-03-28" "2020-03-29" "2020-03-30"
#> [91] "2020-03-31" "2020-04-01" "2020-04-02" "2020-04-03" "2020-04-04"
#> [96] "2020-04-05" "2020-04-06" "2020-04-07" "2020-04-08" "2020-04-09"
#> [101] "2020-04-10" "2020-04-11" "2020-04-12" "2020-04-13" "2020-04-14"
#> [106] "2020-04-15" "2020-04-16" "2020-04-17" "2020-04-18" "2020-04-19"
#> [111] "2020-04-20" "2020-04-21" "2020-04-22" "2020-04-23" "2020-04-24"
#> [116] "2020-04-25" "2020-04-26" "2020-04-27" "2020-04-28" "2020-04-29"
#> [121] "2020-04-30" "2020-05-01" "2020-05-02" "2020-05-03" "2020-05-04"
#> [126] "2020-05-05" "2020-05-06" "2020-05-07" "2020-05-08" "2020-05-09"
#> [131] "2020-05-10" "2020-05-11" "2020-05-12" "2020-05-13" "2020-05-14"
#> [136] "2020-05-15" "2020-05-16" "2020-05-17" "2020-05-18" "2020-05-19"
#> [141] "2020-05-20" "2020-05-21" "2020-05-22" "2020-05-23" "2020-05-24"
#> [146] "2020-05-25" "2020-05-26" "2020-05-27" "2020-05-28" "2020-05-29"
#> [151] "2020-05-30" "2020-05-31" "2020-06-01" "2020-06-02" "2020-06-03"
#> [156] "2020-06-04" "2020-06-05" "2020-06-06" "2020-06-07" "2020-06-08"
#> [161] "2020-06-09" "2020-06-10" "2020-06-11" "2020-06-12" "2020-06-13"
#> [166] "2020-06-14" "2020-06-15" "2020-06-16" "2020-06-17" "2020-06-18"
#> [171] "2020-06-19" "2020-06-20" "2020-06-21" "2020-06-22" "2020-06-23"
#> [176] "2020-06-24" "2020-06-25" "2020-06-26" "2020-06-27" "2020-06-28"
#> [181] "2020-06-29" "2020-06-30" "2020-07-01"
WORKDAY_SEQUENCE("2020-01-01", "2020-07-01")
#> [1] "2020-01-01" "2020-01-02" "2020-01-03" "2020-01-06" "2020-01-07"
#> [6] "2020-01-08" "2020-01-09" "2020-01-10" "2020-01-13" "2020-01-14"
#> [11] "2020-01-15" "2020-01-16" "2020-01-17" "2020-01-20" "2020-01-21"
#> [16] "2020-01-22" "2020-01-23" "2020-01-24" "2020-01-27" "2020-01-28"
#> [21] "2020-01-29" "2020-01-30" "2020-01-31" "2020-02-03" "2020-02-04"
#> [26] "2020-02-05" "2020-02-06" "2020-02-07" "2020-02-10" "2020-02-11"
#> [31] "2020-02-12" "2020-02-13" "2020-02-14" "2020-02-17" "2020-02-18"
#> [36] "2020-02-19" "2020-02-20" "2020-02-21" "2020-02-24" "2020-02-25"
#> [41] "2020-02-26" "2020-02-27" "2020-02-28" "2020-03-02" "2020-03-03"
#> [46] "2020-03-04" "2020-03-05" "2020-03-06" "2020-03-09" "2020-03-10"
#> [51] "2020-03-11" "2020-03-12" "2020-03-13" "2020-03-16" "2020-03-17"
#> [56] "2020-03-18" "2020-03-19" "2020-03-20" "2020-03-23" "2020-03-24"
#> [61] "2020-03-25" "2020-03-26" "2020-03-27" "2020-03-30" "2020-03-31"
#> [66] "2020-04-01" "2020-04-02" "2020-04-03" "2020-04-06" "2020-04-07"
#> [71] "2020-04-08" "2020-04-09" "2020-04-10" "2020-04-13" "2020-04-14"
#> [76] "2020-04-15" "2020-04-16" "2020-04-17" "2020-04-20" "2020-04-21"
#> [81] "2020-04-22" "2020-04-23" "2020-04-24" "2020-04-27" "2020-04-28"
#> [86] "2020-04-29" "2020-04-30" "2020-05-01" "2020-05-04" "2020-05-05"
#> [91] "2020-05-06" "2020-05-07" "2020-05-08" "2020-05-11" "2020-05-12"
#> [96] "2020-05-13" "2020-05-14" "2020-05-15" "2020-05-18" "2020-05-19"
#> [101] "2020-05-20" "2020-05-21" "2020-05-22" "2020-05-25" "2020-05-26"
#> [106] "2020-05-27" "2020-05-28" "2020-05-29" "2020-06-01" "2020-06-02"
#> [111] "2020-06-03" "2020-06-04" "2020-06-05" "2020-06-08" "2020-06-09"
#> [116] "2020-06-10" "2020-06-11" "2020-06-12" "2020-06-15" "2020-06-16"
#> [121] "2020-06-17" "2020-06-18" "2020-06-19" "2020-06-22" "2020-06-23"
#> [126] "2020-06-24" "2020-06-25" "2020-06-26" "2020-06-29" "2020-06-30"
#> [131] "2020-07-01"
HOLIDAY_SEQUENCE("2020-01-01", "2020-07-01", calendar = "NYSE")
#> [1] "2020-01-01" "2020-01-20" "2020-02-17" "2020-04-10" "2020-05-25"
WORKDAY_SEQUENCE("2020-01-01", "2020-07-01",
holidays = HOLIDAY_SEQUENCE("2020-01-01", "2020-07-01",
calendar = "NYSE"))
#> [1] "2020-01-02" "2020-01-03" "2020-01-06" "2020-01-07" "2020-01-08"
#> [6] "2020-01-09" "2020-01-10" "2020-01-13" "2020-01-14" "2020-01-15"
#> [11] "2020-01-16" "2020-01-17" "2020-01-21" "2020-01-22" "2020-01-23"
#> [16] "2020-01-24" "2020-01-27" "2020-01-28" "2020-01-29" "2020-01-30"
#> [21] "2020-01-31" "2020-02-03" "2020-02-04" "2020-02-05" "2020-02-06"
#> [26] "2020-02-07" "2020-02-10" "2020-02-11" "2020-02-12" "2020-02-13"
#> [31] "2020-02-14" "2020-02-18" "2020-02-19" "2020-02-20" "2020-02-21"
#> [36] "2020-02-24" "2020-02-25" "2020-02-26" "2020-02-27" "2020-02-28"
#> [41] "2020-03-02" "2020-03-03" "2020-03-04" "2020-03-05" "2020-03-06"
#> [46] "2020-03-09" "2020-03-10" "2020-03-11" "2020-03-12" "2020-03-13"
#> [51] "2020-03-16" "2020-03-17" "2020-03-18" "2020-03-19" "2020-03-20"
#> [56] "2020-03-23" "2020-03-24" "2020-03-25" "2020-03-26" "2020-03-27"
#> [61] "2020-03-30" "2020-03-31" "2020-04-01" "2020-04-02" "2020-04-03"
#> [66] "2020-04-06" "2020-04-07" "2020-04-08" "2020-04-09" "2020-04-13"
#> [71] "2020-04-14" "2020-04-15" "2020-04-16" "2020-04-17" "2020-04-20"
#> [76] "2020-04-21" "2020-04-22" "2020-04-23" "2020-04-24" "2020-04-27"
#> [81] "2020-04-28" "2020-04-29" "2020-04-30" "2020-05-01" "2020-05-04"
#> [86] "2020-05-05" "2020-05-06" "2020-05-07" "2020-05-08" "2020-05-11"
#> [91] "2020-05-12" "2020-05-13" "2020-05-14" "2020-05-15" "2020-05-18"
#> [96] "2020-05-19" "2020-05-20" "2020-05-21" "2020-05-22" "2020-05-26"
#> [101] "2020-05-27" "2020-05-28" "2020-05-29" "2020-06-01" "2020-06-02"
#> [106] "2020-06-03" "2020-06-04" "2020-06-05" "2020-06-08" "2020-06-09"
#> [111] "2020-06-10" "2020-06-11" "2020-06-12" "2020-06-15" "2020-06-16"
#> [116] "2020-06-17" "2020-06-18" "2020-06-19" "2020-06-22" "2020-06-23"
#> [121] "2020-06-24" "2020-06-25" "2020-06-26" "2020-06-29" "2020-06-30"
#> [126] "2020-07-01"
# Date Collapsers ---
FLOOR_DATE(AS_DATE("2020-01-15"), by = "month")
#> [1] "2020-01-01"
CEILING_DATE(AS_DATE("2020-01-15"), by = "month")
#> [1] "2020-02-01"
CEILING_DATE(AS_DATE("2020-01-15"), by = "month") - ddays(1) # EOMONTH using lubridate
#> [1] "2020-01-31"
# --- Usage with tidyverse ---
# Calculate returns by symbol/year/quarter
FANG %>%
pivot_table(
.rows = c(symbol, ~ QUARTER(date)),
.columns = ~ YEAR(date),
.values = ~ PCT_CHANGE_FIRSTLAST(adjusted)
)
#> # A tibble: 16 × 6
#> symbol `QUARTER(date)` `2013` `2014` `2015` `2016`
#> <chr> <int> <dbl> <dbl> <dbl> <dbl>
#> 1 AMZN 1 0.0357 -0.155 0.206 -0.0681
#> 2 AMZN 2 0.0615 -0.0531 0.172 0.196
#> 3 AMZN 3 0.108 -0.0299 0.170 0.154
#> 4 AMZN 4 0.243 -0.0224 0.298 -0.104
#> 5 FB 1 -0.0864 0.101 0.0481 0.116
#> 6 FB 2 -0.0255 0.0746 0.0502 -0.0153
#> 7 FB 3 1.02 0.161 0.0344 0.123
#> 8 FB 4 0.0839 0.0192 0.151 -0.107
#> 9 GOOG 1 0.0981 0.00174 0.0442 0.00419
#> 10 GOOG 2 0.0988 0.0143 -0.0406 -0.0771
#> 11 GOOG 3 -0.0135 -0.00911 0.166 0.112
#> 12 GOOG 4 0.263 -0.0737 0.241 -0.000958
#> 13 NFLX 1 1.06 -0.0297 0.194 -0.0703
#> 14 NFLX 2 0.157 0.208 0.590 -0.135
#> 15 NFLX 3 0.379 -0.0463 0.103 0.0194
#> 16 NFLX 4 0.134 -0.221 0.0793 0.206
Download the practice file for this video here — Click File > Download > Microsoft Excel.
This video covers the top six functions. Below we cover 20 Excel date functions.
Have you ever noticed that humans are incredibly obsessed with dates? Our level of happiness seems to be inseparably linked to an endless list of appointments, anniversaries, birthdays, holidays, workdays, and weekends. So why shouldn’t our most useful tools have systems for handling these dates of significance?
Managing dates in Excel requires special attention—they’re actually stored as serial numbers, but can be customized to give the appearance of text, or formatted based on local or personal preference.
There are more than 20 Excel date functions, all meant to simplify common operations involving dates.
Three things to know about Excel dates
- Dates in Excel are stored as unique serial numbers, with January 1, 1900 being considered Day 1. Each subsequent day is one day added to Day 1. Therefore January 2, 1900 is stored with serial number 2 and the following day is stored as 3 being the number of days since that date.
- Excel only recognizes dates on or after January 1, 1900. Special workarounds may have to be constructed to handle years between 1 and 1899.
- Changing the number format does not change the value of the number; it only changes the way that value is displayed.
Where to find date functions in Excel
The functions available to you will depend on the version of Excel you’re using. The quickest way to know what date functions are offered by your version of Excel is to click Formulas on the Excel ribbon and select the Date & Time dropdown menu from the Function Library.
Let’s take a look at each date function, its purpose, and how to use it.
Table of contents
1. DATE
(Available in Excel 2007 and subsequent versions)
The DATE function is designed to eliminate confusion when working with dates in Excel.
Because dates can be written in a variety of formats, there can be misunderstandings when everyone isn’t on the same page. This can lead to problems when Excel does not recognize the numbers as dates and handles them in an unexpected way.
The DATE function establishes common ground by asking you to supply each element of your date in a particular order so that Excel assigns the correct date value to your input.
Syntax
The syntax of the DATE function is:
DATE(year, month, day)
All arguments are required.
- The year argument can be one to four digits representing the year. However, it’s recommended that all four digits be used for the year argument to avoid unexpected results. For example, an input of ‘07’ will be interpreted as the year 1907.
- Month is a positive or negative integer representing the month of the year.
- Day is a positive or negative integer representing the day of the month.
Important
- Excel only recognizes dates on or after January 1, 1900, therefore any year argument with a value between 1 and 1899 will be added to 1900. For example, a year of ‘1800’ will result in the year 3700, because 1800 was added to 1900.
- If the month argument is greater than 12, that number of months will be added to the first month of the year argument. For example, DATE(2000,18,1) will return June 1, 2001.
- If a negative value is entered for the month argument, that number of months will be subtracted from the first month of the year argument. For example, DATE(2000,-7,1) will return May 1, 1999.
- If the day argument is greater than the number of days in that month, that number of days will be added to the first day of the month argument. For example, DATE(1999,2,30) will return March 2, 1999.
- If a negative value is entered for the day argument, that number of days will be subtracted from the first day of the month argument. For example, DATE(1999,2,-7) will return January 24, 1999.
The way the date is displayed can be customized by using a built-in date format, or customizing your own.
=DATE(1999,1,24)
In all the above cells, the same formula was entered in all four cells but a different date format was applied to each cell by clicking on Date within the Format Cells dialog box.
Alternatively, you can quickly call up the Format Cells dialog box by pressing the Ctrl+1 shortcut on your keyboard.
Want to learn more?
Take your Excel skills to the next level with our comprehensive (and free) ebook!
2. DATEDIF
(Available in Excel 2007 and subsequent versions)
The purpose of the DATEDIF is to calculate the difference in days, months, or years between two dates. This function is hidden and is not displayed in the Functions menu.
Syntax
Unlike other Excel functions, the syntax of the DATEDIF function does not appear as a tooltip when you type =DATEDIF. This means you’ll definitely need to know the format and how to use this function.
The syntax is:
DATEDIF(start_date, end_date, unit)
All arguments are required.
- Start_date is usually the earlier of the two dates being compared.
- End_date is the later of the two dates being compared.
- Unit is the unit of time (whether days, months, or years) in which you want the results displayed. “Y” returns the number of complete years between the two dates. “M” returns the number of complete months between the two dates. “D” returns the number of days between the dates. The units must be entered within double quotes.
The image below shows an example of how to use DATEDIF in Excel.
This function is especially useful for calculating ages. Note that the “years” unit will only calculate the number of complete years. To return a more precise age, consider using the YEARFRAC function instead.
A less common feature of DATEDIF is the ability to find the difference in days or months between two dates without taking the year into account. To do this, we would use the “YM” or “YD” units.
Note: Though there is an option to find the difference between the days in start_date and end_date by using the “MD” option for the unit argument, this results in a known issue so its use is strongly discouraged by Microsoft.
3. DATEVALUE
(Available in Excel 2007 and subsequent versions)
The DATEVALUE function converts a date formatted as text to a date serial number.
Syntax
DATEVALUE carries a single argument.
DATEVALUE(date_text)
Date_text is a text string in one of Excel date formats. Date_text is entered within double quotation marks if explicit values are used, for example, DATEVALUE(“12/12/1999”). If date_text is a cell reference, no double quotes are used.
=DATEVALUE(“12/12/1999”)
The value returned is the serial number used in Excel to store the date December 12, 1999.
By default, Excel uses your computer’s regional settings to determine date formats. If it does not recognize the input as a valid date, DATEVALUE will return a #VALUE! error.
On a computer that carries a country date setting of month/day/year, a date value of 13-01-87 is interpreted as an invalid date, for which DATEVALUE returns an error. To correct this, you should either adjust your computer’s regional settings or change the text input.
4. DAY
(Available in Excel 2007 and subsequent versions)
The DAY function returns the nth day of the month ranging from 1 to 31. This can be useful for isolating the day element of a date.
Syntax
The syntax of the DAY function is:
DAY(serial_number)
Serial_number is the Excel-assigned number of the date you want to query. The serial number is usually obtained as the result of another Excel function, such as TODAY, DATE, DATEVALUE, etc.
The number format of the output cell can be customized to display the day of the week.
The custom format ‘ddd’ above converts the number to the three-letter abbreviation of day of the week represented by the given serial number. The format ‘dddd’ will return the full name of the day of the week.
5. DAYS
(Available in Excel 2013 and subsequent versions)
The DAYS function calculates the number of days between two dates.
Syntax
The syntax is:
DAYS(end_date, start_date)
- End_date is one of the two dates being compared.
- Start_date is one of the two dates being compared.
Excel returns the difference in the number of days by using the assigned date serial numbers.
The arguments for the DAYS function may be entered as a reference to cells containing the dates.
=DAYS(A2,A1)
Alternatively, the arguments may be explicit dates entered as a text string:
Note that if the end_date is earlier than the start_date, DAYS returns a negative value.
In the example above, the earlier date was entered as the first argument, resulting in a negative integer.
If the date arguments are not considered valid dates, DAYS returns a #VALUE! error.
The above date format is considered incorrect for the local date settings, therefore Excel considers these dates invalid and is unable to calculate the difference between the two dates. To correct this, you should either adjust your computer’s regional settings, or change the text input.
6. DAYS360
(Available in Excel 2007 and subsequent versions)
Accounting periods are often based on twelve 30-day months. The DAYS360 function in Excel calculates the number of days between two dates, based on a 360-day year.
Syntax
The syntax of the DAYS360 is:
DAYS360(start_date,end_date,[method])
- End_date is one of the two dates being compared.
- Start_date is one of the two dates being compared.
- Method (optional) is a setting, set to TRUE or FALSE, that specifies whether to use the U.S. or European method in the calculation. If omitted, FALSE is assumed.
FALSE is the U.S. (NASD) method. If the starting date is the last day of a month, it’s treated as the 30th day of that month. If the ending date is the last day of a month and the starting date is earlier than the 30th day of a month, the ending date is treated as the 1st day of the next month. Otherwise, the ending date becomes equal to the 30th day of the same month. (Source)
TRUE is the European method. Starting dates and ending dates that occur on the 31st day of a month are treated as the 30th day of the same month.
In the above example, the ending date (December 31) is treated as the first day of a new month because the starting date (July 4) is earlier than the 30th of the month, so the result is that 177 days have elapsed. When using the European method, the result is 176 days because the ending date is on the 31st day of the month.
7. EDATE
(Available in Excel 2007 and subsequent versions)
The EDATE function returns the date of a future or past month where the day of the month is identical to the date being referenced. The EDATE function may be used to determine maturity, expiry, or due dates. This function returns the serial number of the calculated date, which can then be formatted using the date format of choice.
Syntax
EDATE(start_date,months)
- Start_date will be used as the reference date.
- Months is the number of months to be calculated before or after the start_date.
It’s recommended that start_date be entered using the DATE function, or reference the result of a formula or function. Using a text string for the first argument could give unexpected results if Excel does not recognize the values as dates.
Months can also be entered as a negative value, which will result in subtracting that number of months from the start date, as shown below.
If a number other than an integer is entered in months, EDATE truncates the decimal and uses the whole number value only (see below).
If the resulting month does not have a date with that numeric value, the last day of the month is returned.
8. EOMONTH
(Available in Excel 2007 and subsequent versions)
The EOMONTH function determines the last day of an earlier or later month than the month being referenced. The EOMONTH function may be used to determine maturity, expiry, or due dates when we want to force these to fall on the last day of the month. This function returns the serial number of the calculated date, which can then be formatted using the date format of choice.
Syntax
EOMONTH(start_date,months)
- Start_date will be used as the reference date.
- Months is the number of months to be calculated before or after the start_date.
In the above example, the investment is set to mature on the last date of the month, three years from the investment date.
It’s recommended that start_date be entered using the DATE function, or reference the result of a formula or function. Using a text string for the first argument could give unexpected results if Excel does not recognize the values as dates.
Months can also be entered as a negative value, which will result in subtracting that number of months from the start date, as shown below.
If a number other than an integer is entered in months, EOMONTH truncates the decimal and uses the whole number value only (see below).
9. ISOWEEKNUM
(Available in Excel 2013 and subsequent versions)
The ISOWEEKNUM function returns the International Organization for Standardization (ISO) week number of the year for the referenced date. The difference between ISOWEEKNUM and WEEKNUM is that ISOWEEKNUM uses the ISO concept of weeks of the year, whereby weeks begin on Monday, and the first week that contains a Thursday is considered Week 1.
Syntax
The syntax of ISOWEEKNUM is:
ISOWEEKNUM(date)
The date argument is the serial number that Excel uses to store dates. Date may be a reference to a cell with a serial number formatted as a date, or it may be the result of another Excel function (for example, DATE or TODAY). Using a text string for the date argument could give unexpected results if Excel misinterprets or does not recognize the value as a date.
ISOWEEKNUM returns an integer between 1 and 53.
In the above example, the first day of the year is a Friday, so it isn’t considered the first week of the year 2021 but rather, a continuation of the 53rd week of 2020.
If the date argument isn’t a valid number (for example, a negative number), ISOWEEKNUM returns the #NUM! error value.
If the date argument isn’t a valid date type (for example, 16/16/2021), ISOWEEKNUM returns the #VALUE! error value.
10. MONTH
(Available in Excel 2007 and subsequent versions)
The MONTH function returns the nth month of the year ranging from 1 to 12. This can be useful for isolating the month element of a date.
Syntax
The syntax of the MONTH function is:
MONTH(serial_number)
Serial_number is the Excel-assigned number of the date you want to query. The serial number is usually obtained as the result of another Excel function, such as TODAY, DATE, DATEVALUE, etc.
In the image above, the DATEVALUE function was used to identify the dates in column A and convert them into a serial number that Excel would recognize as a date. The MONTH function was then used to extract just the month from each date, and represent that number with a value from 1 to 12.
However, unlike the DAY function, changing the number format in the case of the above output cells isn’t a recommended way to display the name of the month, since Excel does not interpret the output values as a date. A better solution would be to use the TEXT function and use the format_text argument to display the name of each month.
The text format “mmmm” causes the TEXT function to return the full name of the month of the year.
Ready to become a certified Excel ninja?
Start learning for free with GoSkills courses
Start free trial
11. NETWORKDAYS
(Available in Excel 2007 and subsequent versions)
NETWORKDAYS is used to determine the number of working days between two dates. The formula calculates the days in an inclusive manner, meaning that the start and end days are included in the count, and Saturdays and Sundays are automatically excluded from the calculation. Additional or ad hoc days may also be excluded using an optional argument.
Syntax
The syntax of the NETWORKDAYS function is:
NETWORKDAYS(start_date, end_date, [holidays])
- Start_date is a date that represents the start date.
- End_date is a date that represents the end date.
- Holidays is an optional argument. It can refer to a range of dates to be excluded from the working days calculation. Alternatively, holidays may be explicitly listed within the formula using an array of date serial numbers.
The basic application of NETWORKDAYS is shown below:
=NETWORKDAYS(DATE(2022,1,1),DATE(2022,12,31),B2:B10)
Note that in the above, the DATE function was used for the start_date and end_date arguments. This ensures that Excel does not misinterpret the date, or fail to recognize the values as dates since dates entered as text may lead to incorrect results. For the holidays argument, the range B2:B10 was referenced.
If any date within the holidays argument is a Saturday or Sunday, no additional action is taken by the NETWORKDAYS function; in other words, there is no ‘double-dipping’.
12. NETWORKDAYS.INTL
(Available in Excel 2010 and subsequent versions)
The NETWORKDAYS.INTL function is used to determine the number of whole working days between two dates. The formula calculates the days in an inclusive manner, meaning that the first and last days are included in the count, but weekend days are excluded. Additional or ad hoc days may also be excluded using an optional argument.
This is a concept similar to NETWORKDAYS, but NETWORKDAYS.INTL offers the flexibility of allowing you to control which days of the week are considered weekend days.
Syntax
The syntax of the NETWORKDAYS.INTL function is:
NETWORKDAYS.INTL(start_date, end_date, [weekend],[holidays])
- Start_date is a date that represents the start date.
- End_date is a date that represents the end date.
- Weekend is an optional argument. This argument controls the days of the week that are not included in the number of whole working days between start_date and end_date. The weekend argument may be entered as a number string within double quotes or using the Excel-defined number representing when weekends occur. If this argument is omitted, Saturdays and Sundays are assumed to be weekend days.
The basic application of NETWORKDAYS.INTL is shown below:
=NETWORKDAYS.INTL(DATE(2022,1,1),DATE(2022,12,31),,B2:B10)
Note that the DATE function was used for the start_date and end_date arguments. This ensures that Excel does not misinterpret the date, or fail to recognize the values as dates. Dates entered as text may lead to incorrect results. For the holidays argument, the range B2:B10 was referenced.
Note also that in the above example, the weekend argument was omitted, and the formula defaulted to Saturdays and Sundays as weekend days. However, if we wanted to designate Fridays and Saturdays as weekend days, we would need to specify this by using the value 7 or the number string “0000110”.
=NETWORKDAYS.INTL(DATE(2022,1,1),DATE(2022,12,31),7,B2:B10)
or
=NETWORKDAYS.INTL(DATE(2022,1,1),DATE(2022,12,31),”0000110”,B2:B10)
If any date within the holidays argument is a designated weekend day, no additional action is taken by the NETWORKDAYS function. In other words, there is no ‘double-dipping’. See below, where the removal of the April 15 and July 1 dates has no effect since, with Fridays being weekend days, they were already subtracted from the workdays count.
13. NOW
(Available in Excel 2007 and subsequent versions)
The NOW function in Excel returns the serial number of the current date and time. When NOW is used in a cell, a date format matching your computer’s regional settings is applied. The NOW function is considered ‘volatile’, meaning that it updates automatically whenever the worksheet is opened, or when the formulas are manually recalculated.
Syntax
The NOW function has no arguments. The format is:
=NOW()
Of course, the number format can be adjusted to display dates and times as per your personal preference by going to the Format Cells dialog box (Ctrl+1 shortcut), then selecting from an available number format from the Date category. Date formats can be further customized by selecting the Custom category.
The date and time can be refreshed within an open worksheet by going to the Formulas tab on the ribbon. Then select Calculate Now (F9 shortcut) to recalculate all formulas in the entire workbook. Or select Calculate Sheet (Shift+F9) to recalculate formulas within the current worksheet only.
The NOW function can be modified to create formulas that calculate a future or past date and time relative to the current date and time.
=NOW()+7
With the above formula, Excel calculates the date and time exactly seven days from now.
If you imagine that the 24 hours making up an entire day is a whole represented by the number 1, then the fraction 0.5 would be equal to half of the day, or 12:00 PM. Various times of the day could also be represented by different fractions (for example 0.25 would be 6:00 AM, 0.95 would be 10:48 PM and so on). Therefore, we can also alter the NOW function to calculate a future or past date and time, which is a fraction of the current date and time.
=NOW()-1.5
The above formula returns the date and time one and a half days (or 36 hours) prior to the current day and time.
14. TODAY
(Available in Excel 2007 and subsequent versions)
The TODAY function returns the serial number of the current date in Excel. When TODAY is used in a cell, a date format matching your computer’s regional settings is applied. The TODAY function updates automatically whenever the worksheet is opened, or when the formulas are manually recalculated.
Syntax
The TODAY function has no arguments. The format is:
=TODAY()
Of course, the number format can be adjusted to display the date as per your personal preference by going to the Format Cells dialog box (Ctrl+1 shortcut), then selecting from an available number format from the Date category. Date formats can be further customized by selecting the Custom category.
Each time the workbook is opened, the date is recalculated and the current date is displayed. To refresh the date within an open workbook, go to the Formulas tab on the ribbon. Then select Calculate Now (F9 shortcut) to recalculate all formulas in the entire workbook, or select Calculate Sheet (Shift+F9) to recalculate formulas within the current worksheet only. These options are found within the Calculation command group.
The TODAY function can be modified to create formulas that calculate a future or past date relative to the current date.
=TODAY()+7
With the above formula, Excel calculates the date seven days from today.
The TODAY function can also be combined with other Excel functions to extract a single element from today’s date, i.e. today’s year, month of the year, or the day of the month.
With this principle, we can also calculate the number of years elapsed between today and another date.
=YEAR(TODAY())-1983
15. WEEKDAY
(Available in Excel 2007 and subsequent versions)
The WEEKDAY function returns a number that represents the nth day of the week, ranging from 1 to 7 (or, in some cases, 0 to 6). The function also carries an optional argument that allows you to state the numbers which should represent each day.
Syntax
The syntax of the WEEKDAY function is:
WEEKDAY(serial_number,[return_type])
Serial_number is the Excel-assigned number that represents the date you want to query. The serial number is usually obtained as the result of another Excel function, such as TODAY, DATE, DATEVALUE, etc.
Return_type is an optional argument that determines the type of return value. If return_type is omitted, 1 is assumed.
Return_Type Argument |
Weekday Values |
---|---|
1 or omitted |
1 through 7, Sunday — Saturday |
2 |
1 through 7, Monday — Sunday* |
3 |
0 through 6, Monday — Sunday |
11 |
1 through 7, Monday — Sunday* |
12 |
1 through 7, Tuesday — Monday |
13 |
1 through 7, Wednesday — Tuesday |
14 |
1 through 7, Thursday — Wednesday |
15 |
1 through 7, Friday — Thursday |
16 |
1 through 7, Saturday — Friday |
17 |
1 through 7, Sunday — Saturday |
*The WEEKDAY function is available in all Excel versions, but only return_types 1, 2, and 3 were available before Excel 2010. Return_types 2 and 11 are identical in functionality.
Basic application
This function can be used to identify the day of the week on which a particular date falls. Each day of the week is represented by a number, the default being that the number 1 represents Sunday, 2 represents Monday, and so on.
=WEEKDAY(DATE(1979,8,14))
The above formula asks Excel to check the date August 14, 1979 and return the number which represents the day of the week. Since no return_type was entered, Sunday is considered the first day of the week and is represented by the number 1. Therefore, the return value of 3 means that date was a Tuesday.
The serial number may also refer to a date value in another cell. In the example below, the date is entered in cell A1. Excel recognizes this entry as a date value, converts the value to the date’s serial number, and displays the date in a format accepted by the computer’s regional date settings.
In the background, Excel has stored the date as a unique serial number representing the date that is the result of the calculation. If you change the number format to General, the serial number will be displayed.
From this, you can see that we can now reference cell A1 with the WEEKDAY function to determine what day of the week that date was.
Display day of the week by name
The value returned by the WEEKDAY function can be converted to display the weekday name by adding the TEXT function.
=TEXT(WEEKDAY(A1),”ddd”)
Using the 4-character code “dddd” will result in the full name of the weekday. This method works well when Sunday is the designated first day of the week.
When Sunday isn’t the first day of the week
In some settings, a day other than Sunday is considered the first day of the week. For example, in some workplaces, Monday is designated as the first day of the week, and Sunday as the last. In those cases, it may be preferable to use the return_type argument of the WEEKDAY function to identify the weekday on which a particular date falls.
=WEEKDAY(DATE(2022,1,1),2)
Since 2 was used as the return_type of the WEEKDAY function, an output of 6 means that January 1, 2022 is a Saturday. It’s very important to point out that when the week begins on a day other than Sunday, the TEXT function will not return the correct value for the name of the weekday.
One workable solution is to use the SWITCH function to declare alternate values for each possible result.
The syntax of the SWITCH function is:
=SWITCH(expression, value1, result1, [default or value2, result2],…[default or value3, result3])
In this case, we will not use a default value, since the result of the WEEKDAY formula will always fall between 1 and 7.
=SWITCH(WEEKDAY(A2,2),1,"Monday",2,"Tuesday",3,"Wednesday",4,"Thursday",5,"Friday",6,"Saturday",7,"Sunday")
16. WEEKNUM
(Available in Excel 2007 and subsequent versions)
The WEEKNUM function returns the week number of the year for the referenced date. The difference between ISOWEEKNUM and WEEKNUM is that WEEKNUM uses two possible systems to determine the week number, whereas ISOWEEKNUM uses the ISO standard.
- With System 1, the week containing January 1 is always considered Week 1.
- With System 2, the week containing the first Thursday of the year is considered Week 1. This system is commonly known as the European week numbering system and is the one used with the ISOWEEKNUM function.
WEEKNUM returns an integer between 1 and 54.
Syntax
The syntax of WEEKNUM is:
WEEKNUM(serial_number, [return_type]))
- Serial_number is a unique number that Excel uses to store each date.
- Return_type is an optional argument that determines the type of return value. If return_type is omitted, 1 is assumed.
The following options are available options for the return_type argument.
Return_type Argument |
Week Begins on |
System |
---|---|---|
1 or omitted |
Sunday |
1 |
2 |
Monday* |
1 |
11 |
Monday* |
1 |
12 |
Tuesday |
1 |
13 |
Wednesday |
1 |
14 |
Thursday |
1 |
15 |
Friday |
1 |
16 |
Saturday |
1 |
17 |
Sunday |
1 |
21 |
Monday |
2 |
*The WEEKNUM function is available in all Excel versions, but only return types 1 and 2 were available before Excel 2010. Return types 2 and 11 are identical in functionality.
Basic application
In its default setting, WEEKNUM assumes that the week begins on a Sunday. If the first day of the year is a Sunday, January 1-7 are considered Week 1. If the first day of the year is any day other than a Sunday, Week 1 would begin on January 1 and end on the first Saturday of the year. Week 2 would begin on the first Sunday of the year.
=WEEKNUM(A2)
If Monday is the designated first day of the week, return_type 2 should be selected.
=WEEKNUM(A2,2)
Return_type 21 behaves very differently, whereby Week 1 will be the first week containing a Thursday. Otherwise, the week number will continue from the previous year, and the week begins on Monday. With this setting, WEEKNUM behaves the same as the ISOWEEKNUM function.
If the date argument isn’t a valid number (for example, a negative number), WEEKNUM returns the #NUM! error value.
If the date argument isn’t a valid date type (for example, 16/16/2021), WEEKNUM returns the #VALUE! error value.
17. WORKDAY
(Available in Excel 2007 and subsequent versions)
The WORKDAY function calculates the date, which is n number of working days before or after a starting date. The starting date isn’t included in the number of days being counted. Saturdays and Sundays are automatically excluded from the count. Holidays may also be excluded using an optional holiday argument.
Syntax
WORKDAY(start_date, days, [holidays])
- Start_date is the date to be used for reference.
- Days is the number of days to add to or subtract from start_date. Saturdays and Sundays are ignored if they fall within the range of days. A negative days value will result in a past date.
- Holidays is an optional argument. It can refer to a range of one or more dates to be excluded from the working days calculation. Alternatively, holidays may be explicitly listed within the formula using an array of date serial numbers.
Basic application
WORKDAY is typically used to calculate the end date of a project when the estimated number of workdays is known. An example is shown below.
Since the project spans a Saturday and a Sunday, these days are not included in the seven-day count and the project will end nine calendar days after the start date.
The use of the optional holiday argument allows additional days to be excluded from the number of working days.
=WORKDAY(D2,E2,B2:B10)
18. WORKDAY.INTL
(Available in Excel 2010 and subsequent versions)
The WORKDAY.INTL function returns the serial number of the date, which is the specified number of working days before or after a starting date. This function is similar to the WORKDAY function, but WORKDAY.INTL offers the flexibility of allowing you to control which days of the week are considered weekend days.
Syntax
The syntax of the WORKDAY.INTL is:
WORKDAY.INTL(start_date, days, [weekend], [holidays])
- Start_date is the start date to be used as a reference.
- Days is the number of days to add to or subtract from start_date. Saturdays and Sundays are ignored if they fall within the range of days. A negative days value will result in a past date.
- Weekend is an optional argument. This argument controls the days of the week that aren’t included in the number of whole working days between start_date and end_date. The weekend argument may be entered as a number string, or by using the Excel-defined number representing when weekends occur. If this argument is omitted, Saturdays and Sundays are assumed to be weekend days. See the table below for possible values for the weekend argument.
- Holidays is also an optional argument. It can refer to a range of one or more dates to be excluded from the working days calculation. Alternatively, holidays may be explicitly listed within the formula using an array of date serial numbers.
Weekend Argument Value |
Weekend Day(s) |
---|---|
1 or omitted |
Saturday, Sunday |
2 |
Sunday, Monday |
3 |
Monday, Tuesday |
4 |
Tuesday, Wednesday |
5 |
Wednesday, Thursday |
6 |
Thursday, Friday |
7 |
Friday, Saturday |
11 |
Sunday only |
12 |
Monday only |
13 |
Tuesday only |
14 |
Wednesday only |
15 |
Thursday only |
16 |
Friday only |
17 |
Saturday only |
Alternatively, the weekend argument may be represented by a number string entered within double quotation marks where weekend days are represented by the number 1, and workdays are represented by 0. Monday is the first day of the week in the number string. Using this system, the number string “0000110” represents a week where Friday and Saturday are weekend days.
Basic application
WORKDAY.INTL is typically used to calculate the end date of a project when the estimated number of workdays is known, especially when weekend days aren’t the default Saturday and Sunday combination. An example is shown below, where Sundays are to be considered weekend days.
=WORKDAY.INTL(A2,B2,11)
The weekend argument is given a value of 11 since Sundays are the only days to be considered weekend days. Since the project spans a Sunday, that day isn’t included in the seven-day count and the project will end eight calendar days after the start date.
The use of the optional holiday argument allows additional days to be excluded from the number of working days.
=WORKDAY.INTL(D2,E2,11,B2:B10)
When no days should be excluded
What if you would like to calculate the end date without excluding any weekend days or holidays? Perhaps the project will be worked on every day until completion. In that case, the DAYS function should be used instead.
19. YEAR
(Available in Excel 2007 and subsequent versions)
The YEAR function returns the year corresponding to a date. This can be useful for isolating the year element of a date.
Syntax
The syntax of the YEAR function is:
YEAR(serial_number)
Serial_number is the Excel-assigned number of the date you want to query. The serial number is usually obtained as the result of another Excel function, such as TODAY, DATE, DATEVALUE, etc.
In the image above, the DATEVALUE function is used to identify the dates in column A and convert them into a serial number that Excel would recognize as a date. The YEAR function is then used to extract just the year from each date.
Want to learn more?
Take your Excel skills to the next level with our comprehensive (and free) ebook!
20. YEARFRAC
(Available in Excel 2007 and subsequent versions)
The YEARFRAC function calculates the number of days between two dates (the start_date and the end_date) as a fraction of the entire year. The output value is a decimal. This function can be useful for calculating one’s age to a fraction.
Syntax
The syntax of the YEARFRAC function is:
YEARFRAC(start_date, end_date, [basis])
- Start_date is one of the two dates being compared.
- End_date is one of the two dates being compared.
- Basis is an optional argument that controls the type of day count to be used. See the table below for possible options.
YEARFRAC Basis Value |
Calculation |
Remarks |
---|---|---|
0 or omitted |
30/360 |
US system |
1 |
# of days/days in the year |
|
2 |
# of days/360 |
|
3 |
# of days/365 |
|
4 |
30/360 |
European system |
Both the U.S. and European systems assume years consisting of twelve 30-day months.
The U.S. (NASD) method assumes a year to consist of twelve 30-day months. If the starting date is the last day of a month, it’s treated as the 30th day of that month. If the ending date is the last day of a month and the starting date is earlier than the 30th day of a month, the ending date is treated as the 1st day of the next month. Otherwise, the ending date becomes equal to the 30th day of the same month (Source).
The European method also assumes a year to consist of twelve 30-day months. However, starting dates and ending dates that occur on the 31st day of a month are treated as the 30th day of the same month.
Conclusion
Now you understand how Excel dates work and how you can simplify the way they are processed with one of these incredibly useful Excel DATE functions.
To learn more Excel, try our courses, including one of our most popular courses Microsoft Excel — Basic to Advanced.
Ready to become a certified Excel ninja?
Start learning for free with GoSkills courses
Start free trial
There are many functions in Microsoft Excel that may be used to work with dates and timings in Excel. Each function completes a straightforward task, but by combining numerous functions into a single formula, you may handle trickier and more complicated problems. The purpose of discussing DATE functions in Excel is to help different people to perform more complex and challenging tasks by combining several functions within one formula.
The DATE function is used to calculate dates in Excel. Excel provides different functions to work with dates & times such as TODAY, NOW, WEEKDAY, EOMONTH, etc. which we will discuss here with examples.
1. DATE Function in Excel
It will return the date in serial number based on the year, month, or day value as provided.
Syntax:
DATE(year,month,day)
Arguments:
- Year – This argument includes – 1 to 4-digit values. Excel understands this ‘year’ argument according to the date system of the local computer which we use. For example- Excel windows uses the 1900 date system by default which means DATE (21,2,6) gives the result as 06-02-1921.
- Month – This argument includes a positive or negative integer that represents the month of the year from January to December.
- Day – This argument also includes a positive or negative integer representing the day of the month from 1 to 31.
Excel Date Function Example 1:
Excel Date Function Example 2:
It will return on the first day of the current year & month.
Excel Date Function Example 3:
2. TODAY Function in Excel
The TODAY() function name suggests it will return today’s date, and it has no arguments.
Syntax:
TODAY()
Example1:
Here we will print the current date and also add 10 days to the current date.
Example 2:
To add 10 days to Today’s date.
3. NOW Function in Excel
This function returns the current date as well as the time & doesn’t have any arguments.
Syntax:
NOW()
Example:
4. DATEVALUE Function
It converts the date in text format to a serial number, which can be represented as a date.
Syntax:
DATEVALUE(date_text)
Arguments:
1. date_text – This argument is a text that represents the date in Excel date format.
Example:
5. TEXT Function
It converts any numeric value not only dates to a text string. Through this function, we can change the date to text strings in a variety of formats.
Syntax:
TEXT(value,format_text)
Arguments:
1. value: The value that is to be converted.
2. format_text: The format in which you want to output the date value.
These are the different formats used in the TEXT function to change dates to text strings.
Example 1:
Example 2:
Example 3:
6. DAY Function
It returns the day of a month, i.e. integer from 1 to 31.
Syntax:
DAY(serial_number)
Arguments:
1. serial_number: This value represents the day of the month you want to find. E.g: 5th day of June
Example 1:
Example 2:
The DAY(TODAY()) function returns the day of today’s date, as shown below:
7. MONTH Function
This function returns the month of the given date as an integer from 1 to 12 (January to December).
Syntax:
MONTH(serial_number)
Arguments:
1. serial_number: This value represents the date for which you want to find the month.
Example:
The MONTH(TODAY()) function returns the month of today’s date.
8. YEAR Function
It returns the year of a specified date.
Syntax:
YEAR(serial_number)
Arguments:
1. serial_number: The date to be specified.
Example 1:
Example 2:
Example 3:
9. EOMONTH Function
This function returns the last day of the month after adding a specified number of months to a given date.
Syntax:
EOMONTH(start_date,months)
Arguments:
1. start_date: In this argument, the date should be written in date format, not in the text.
2. months: In this argument, if a positive integer is given then corresponding months can be added to the start date & if a negative integer is given then the corresponding months can be subtracted from the start date.
Example 1:
Example 2:
Example 3:
The EOMONTH(TODAY(),0) function returns the last day of the current month.
10. WEEKDAY Function
This function returns the day of the week as a number from 1 to 7 (Sunday to Saturday) according to the specified date.
Syntax:
WEEKDAY(serial_number,return_type)
Arguments:
1. serial_number: It can be a date or the cell that contains the date.
2. return_type: It is optional, as it specifies which day should be considered as the first day of the week.
NOTE: 1st day of the week is by default Sunday.
Example 1:
Example 2:
In the below example, 2 is given as return_type i.e. Monday is referred to as the first day of the week.
Example 3:
Here the day of today’s (01-04-2021) date is the result & the default value (Sunday) is considered here because no return_type is given.
11. DATEDIF Function
This function calculates the difference between two dates in days, months, or years. For calculating the difference b/w dates which time interval should be used depends on the letter which we specify in our last argument i.e. at the unit.
Syntax:
DATEDIF(start_date,end_date,unit)
Arguments:
1. start_date: The start date for evaluating the difference.
2. end_date: The end Date for evaluating the difference.
Example 1:
Example 2:
Example 3:
Here “m”,”y”,”d” means month, year & date. In the first example, the difference between dates is calculated by months, second by year & third by date.
12. WEEKNUM Function
It returns the week number based on the specified date, i.e. from 1 to 52 weeks of the year.
Syntax:
WEEKNUM(serial_number,firstday_ofweek)
Arguments:
1. serial_number: This is the date for which we want the week number.
2. firstday_ofweek: This is an optional argument that specifies which numbering system should be considered & which day of the week can be treated as the start of the week, Default(omitted) is 1. The table below is the parameters that can be given in firstday_ofweek argument.
First Day of the Week Start Table:
1 | Sunday | 1 |
2 | Monday | 1 |
11 | Monday | 1 |
12 | Tuesday | 1 |
13 | Wednesday | 1 |
14 | Thursday | 1 |
15 | Friday | 1 |
16 | Saturday | 1 |
17 | Sunday | 1 |
21 | Monday | 2 |
Example 1:
Example 2:
Example 3:
In the below example,21 is given as the second argument which means Monday is taken as the first day of the week & in the above example, the result shown is 15 but taking 21 as the first_dayofweek means Monday is the first day, the result is 14.
13. EDATE Function
This function adds or subtracts the specified month to a given date.
Syntax:
EDATE(start_date,months)
Arguments:
1. start_date: This is an initial date on which the months are added or subtracted.
2. months: This is the number of months which is to be added or subtracted in the specified date.
Example 1:
Example 2:
Example 3:
14. YEARFRAC Function
This function returns the fraction of the year which represents the number of whole days between the start & end date.
Syntax:
YEARFRAC(start_date,end_date,[basis])
Arguments:
1. start_date: This is the start date in the serial number.
2. end_date: This is the end date in the serial number.
3. basis: This is the optional argument that specifies the day count method.
Basis | Day count method |
---|---|
0(default) | US 30/360 |
1 | actual/actual |
2 | actual/360 |
3 | actual/365 |
4 | European 30/360 |
Example 1:
Using someday count methods.
Example 2:
Example 3:
15. WORKDAY Function
This function helps if we exactly know how many working days we have & want to find out the date when the number of working will skip. This function always includes working days & excludes weekend days.
Syntax:
WORKDAY(start_date,days,holidays)
Arguments:
1. start_date: This argument is the date from which the counting of weekdays begins. Excel doesn’t include start_date as a working day.
2. days: This is the number of working days.
3. holidays: This is an optional argument. If the days mentioned include any holidays, then we need to make a list of holidays separately for this, and mention it here.
Example 1:
28 workdays from the start date, excluding holidays.
Example 2:
28 workdays before the start date, excluding holidays
Example 3:
28 workdays from the start date, no holidays.
Example 4:
28 workdays from today’s date, no holidays.
16. WORKDAY.INTL Function
This is a modification of the WORKDAY function as it provides a custom weekend parameter that distinguishes this from the WORKDAY function.
Syntax:
WORKDAY.INTL(start_date,days,[weekends],holidays)
Arguments:
1. start_date: This argument is the date from which the counting of weekdays begins. Excel doesn’t include start_date as a working day.
2. days: This is the number of working days.
3. holidays: This is an optional argument. If the days mentioned include any holidays, then we need to make a list of holidays separately for this and mention it here.
4. weekends: Through this argument, we can specify which days of the week to be treated as non-working days, either by weekend number or specific character string.
Weekend Number:
Numbers | Days |
---|---|
1 (default) | Saturday, Sunday |
2 | Sunday, Monday |
3 | Monday, Tuesday |
4 | Tuesday, Wednesday |
5 | Wednesday, Thursday |
6 | Thursday, Friday |
7 | Friday, Saturday |
11 | Sunday |
12 | Monday |
13 | Tuesday |
14 | Wednesday |
15 | Thursday |
16 | Friday |
17 | Saturday |
If this weekend argument is blank in this function, then it will automatically take the combination of Saturday & Sunday.
For instance:
- “0000011”-Saturday & Sunday are weekends(non-working days)
- “1000010”-Monday & Saturday are weekends(non-working days)
Example 1:
30 days from the start date, excluding holidays & Sunday, and Monday as weekends (by giving weekend number 2 as arguments).
Example 2:
30 days from the start date, excluding holidays & Sunday, Monday as weekends(by giving weekend string “1000001” as arguments).
Example 3:
20 days from the start date, no holidays & Monday, Saturday as weekends (by giving weekend string “1000010” as arguments).
17. NETWORKDAYS Function
This function returns the number of working days between two dates, excluding weekends & holidays are as optional arguments.
Syntax:
NETWORKDAYS(start_date,end_date,holidays)
Arguments:
1. start_date: The initial date to start evaluation.
2. end_date: The last date to end the evaluation.
4. holidays: Used to specify holidays.
Example 1:
Example 2:
18. NETWORKDAYS.INTL Function
This function also returns the number of working days between two dates but provides the additional argument weekend to specify which days should be counted as weekend days.
The structure of the weekend argument is the same as for WORKDAY.INTL i.e. we can use either the weekend number or character string.
Syntax:
NETWORKDAYS.INTL(start_date,end_date,[weekend],holidays)
Arguments:
1. start_date: The initial date to start the evaluation.
2. end_date: The last date to end the evaluation.
3. weekend: Use to specify the weekends.
4. holidays: Used to specify holidays.
Example 1:
Here, the weekend argument is given in the form of a number.
Example 2:
Here, the weekend argument is given in the form of a character string of 0’s & 1’s.
Hopefully, this extensive overview of Excel’s date functions has given you a general idea of how date formulas in Excel operate. I advise you to read more articles on Excel if you want to understand more. I appreciate your time and look forward to hearing from you soon!
FAQs on DATE Functions in Excel
Here are some of the most frequently asked questions on DATE Functions in Excel
1. What is a Date function?
The DATE function in Excel combines the three independent values of year, month, and day to create a date.
Syntax: DATE(year,month,day)
2. How do I get DD MMM YYYY in Excel?
- Pick the cell that contain the date>right-click and select Format Cells
- Select Custom in the Number Tab>type ‘dd-mmm-yyyy’ in the Type text box>click OK.