Skip to main content

Time Unit Descriptors Supported by Date Functions

Introduction

When using the following two date functions, you need to fill in the "units" parameter of timing unit:

DATEADD(date, count, units)
DATETIME_DIFF(date1, date2, units)

The DATEADD() function adds a certain time interval to the specified date, where 「count」 is the time interval and 「units」 is the timing unit.

The DATETIME_DIFF() function returns the difference (positive or negative) between two dates in the specified timing units. The default timing unit 「units」 is seconds.

The following are the time unit descriptors supported by the two functions, along with the abbreviations for each time unit.When using the descriptors in both functions, filling in both the full name and the abbreviation will work.

Unit descriptorAbbreviation** **
"milliseconds""ms"
"seconds""s"
"minutes""m"
"hours""h"
"days""d"
"weeks""w"
"months""M"
"quarters""Q"
"years""y"

Example

The expected completion time for this project is 10 days, and the expected end date of the project needs to be calculated as follows:

DATEADD({start time}, 10, "days")

After starting the project, if you want to know how many days this project has left until the expected end:

DATETIME_DIFF({cutoff time}, TODAY(), "days")