Google Sheets TODAY Function | DATEDIF Function | How to Use TODAY and DATEDIF

Опубликовано: 19 Апрель 2021
на канале: Software Spring
53,450
258

Use the Google Sheets TODAY function to get today's date. It's one of the simplest functions of Google Sheets, because it does not need any attributes. Note that TODAY always gives the current date. Use the DATEDIF function to get the number of years, months, or days between two dates.

TODAY Function

The TODAY function returns the date in month/day/year format.

Let's look at the format of the TODAY function formula:

=TODAY()

Start the formula with an equal-to symbol.

TODAY is the name of the function.

Here is an example of TODAY:

If today is April 14, 2021, then the function

=TODAY()

returns

4/14/2021.

DATEDIF Function

If you wish to find out the number of days, months, or years, in absolute or relative terms, between two dates, you can use the DATEDIF function.

Here is the format of the DATEDIF function formula:

=DATEDIF(start_date, end_date, unit)

Start the formula with an equal-to symbol.

DATEDIF is the name of the function.

start_date is the first date of the date range.

end_date is the end date of the date range.

unit takes one of the following values:

"Y", use it to get the absolute years between two dates.

"M", use it to get the absolute months between two dates.

"D", use it to get the absolute days between two dates.

"YM", use it to get the fractional year, between the two dates, in whole months.

"MD", use it to get the fractional months, between the two dates, in days .

"YD", use it to get the days between the current year's or last year's corresponding date of the start date and end date.

Let's look at some examples of the DATEDIF function:

Example 1

Say you want to find out the number of years from the date you made an investment in the shares of a company and today's date. Assume that you want to ignore any fractional year.

Assume that cell A1 is labelled Investment Date and cell B1 is labelled Today. Say cell A2 has the value 03/10/2019 and cell B2 should have today's date obtained using TODAY function.

The DATEDIF function formula is:

=DATEDIF(A2, B2, "Y")

If today is 04/14/2021, the function returns 2 as the number of years between 03/10/2019 and 04/14/2021.

Example 2

Using the same scenario and data as in Example 1, say that you want to find out the number of months that have lapsed from the date you made the investment and today's date.

The DATEDIF function formula is:

=DATEDIF(A2, B2, "M")

If today is 04/14/2021, the function returns 25 as the number of months between the start date and end date.

Example 3

Again, using the same scenario and data as in Example 1, say that you want to find out the number of years, months, and days that have lapsed from the date you made the investment and today's date.

Assume that cells C1, D1, and E1 are labelled Years, Months, and Days.

Type the DATEDIF function formula in cell C2 to get the time in absolute years:

=DATEDIF(A2, B2, "Y")

The function returns 2 as the number of years.

Type the DATEDIF function formula in cell D2 to get the time in non-absolute months:

=DATEDIF(A2, B2, "YM")

The function returns 1 as the number of months.

Type the DATEDIF function formula in cell E2 to get the time in non-absolute days:

=DATEDIF(A2, B2, "MD")

The function returns 4 as the number of days.

Do take a look at this video tutorial, which gives the steps to use the Google Sheets TODAY and DATEDIF functions with examples.