Dates are internally stored as sequential serial numbers in Google Sheets. This serial number represents the number of days elapsed since December 31, 1899.
You can use the
DATEVALUE function to convert any date input to a number that represents the date. For instance, both the functions
DATEVALUE("Jan 1") and
DATEVALUE("01-Jan-2021") return the same number (44197) though the inputs have vastly different formats.
TODAY() returns the current date while the function
NOW() returns the current date and time. Both these functions do not require any arguments and they update when any cell in the Google Sheet is changed.
NOW() + 2 returns the current date and time plus two days while
NOW() - 9/24 returns the date and time 9 hours ago since 1 = 24 hours.
DAY() can be used extract the year, month and day of the date that is passed as an argument.
DAYS() function calculates the number of days between two dates. Internally, it calculates the
DATEVALUE of the first date and the
DATEVALUE of the second date and subtracts the two numbers.
If you want to calculate the number of months between two dates, you can use the
DATEDIF() function with the third argument set to
M. For instance, the function
=DATEDIF("Jan 1, 1951", TODAY(), "M") returns the number of months between January 1951 and today.
YEARFRAC() function calculates the number of years that has passed between two dates.
EDATE() function to calculate a date that is a specified number of months before or after a specified date. For instance,
EDATE(TODAY(), -1) returns the date that is one month before the current date.
EOMONTH() function helps you calculate the last day of the given month. For instance,
EOMONTH(TODAY(), -1) returns the last day of the previous month. Add
1 to the result,
=EOMONTH(TODAY(),-1)+1, and you’ll get the first day of the current month.
WEEKDAY() function returns the day of the week corresponding to a date with Sunday representing 1, the first day of the week. Set the second argument to
2 and days of the week will be numbered starting with Monday.
WORKDAY() function calculates the date that is a specified number of days before or after a specified date, excluding weekends. For instance,
WORKDAY(TODAY(), -7) returns the date that is 7 working days before the current date.
NETWORKDAYS() function calculates the number of working days between two dates provided as arguments. Combine this with
EOMONTH to calculate the number of working days that are left till the end of the the current month
|Add number of days to a date|
|Get a day that is 6 months prior to a date|
|Add number of years to a date|
|Difference in days between two dates|
|Total working days between two dates|
|Get a date that is 10 working days from now|
|Get the total number of months between two dates|
|Get the difference in years between two dates|
|Get the number of days in the current month|
|Print the day of the week|
|Calculate the age in years|
|Days until your next birthday|
|Months and days between two dates|
You can copy this Google Sheet to get all the working formulas mentioned in this tutorial.