Can you use DATEDIF fx in google sheets without first entering the dates into cells?

39 Views Asked by At

I'm taking a class in Data Analytics, and I'm trying to improve my Google Sheets and Excel skills. (I'm a beginner!)

I'm trying to gain fluency with using DATEDIF. When I type =DATEDIF(MM/DD/YYYY, MM/DD/YYYY, "D") it returns an error. If I put the dates into two cells first, and then type =DATEDIF (cell, cell, "D") it works just fine.

Is that just how DATEDIF is supposed to work or am I doing something wrong? I'm making sure my dates are formatted correctly, and consistently. Thank you!

I tried entering the dates in the formula, rather than in cells first.

1

There are 1 best solutions below

0
doubleunary On

From the documentation:

TO_DATE(10/10/2000) is interpreted as TO_DATE(0.0005), the quotient of 10 divided by 10 divided by 2000.

Use this syntax:

=datedif(datevalue("2023-01-01"), datevalue("2023-12-31"), "d")

...or simply let Sheets autoconvert text strings to dates, as suggested in the comment, like this:

=datedif("2023-01-01", "2023-12-31", "d")

...or skip datedif() altogether, like this:

="2023-12-31" - "2023-01-01"

See Working with date and time values in Google Sheets.