Date functions
This article explains various date functions that can be used in formula fields.
This cheat sheet provides a quick reference guide for various date functions commonly used in data analysis and programming. Each function is accompanied by its syntax, a sample usage, and a brief description.
DATETIME_DIFF
The DATETIME_DIFF function calculates the difference between two dates in various units.
Syntax
Sample
Remark
This function compares two dates and returns the difference in the specified unit. Positive integers indicate that the second date is in the past compared to the first, and vice versa for negative values.
DATEADD
The DATEADD function adds a specified value to a date or datetime.
Syntax
Sample
Conditional Example
Remark
This function supports date and datetime fields and can handle negative values.
NOW
The NOW function returns the current time and day.
Syntax
Sample
Conditional Example
Remark
This function provides the current time and day, supporting datetime fields and negative values.
WEEKDAY
The WEEKDAY function returns the day of the week as an integer.
Syntax
Sample
Remark
Returns the day of the week as an integer between 0 and 6 (inclusive), with Monday as the default start day. The start day of the week can be optionally changed by specifying it as the second argument.
DATESTR
The DATESTR function converts a date or datetime field into a string in "YYYY-MM-DD" format.
Syntax
Sample
Remark
This function converts a date or datetime field into a string in "YYYY-MM-DD" format, ignoring the time part.
DAY
The DAY function returns the day of the month as an integer.
Syntax
Sample
Remark
This function returns the day of the month as an integer between 1 and 31 (inclusive). Note that the day information retrieved is based on the timezone of the server (GMT by default). If the browser timezone is different from the server timezone, the day value may differ.
YEAR
The YEAR function returns the year as an integer.
Syntax
Sample
Remark
This function returns the year as an integer. The year information retrieved is based on the timezone of the server (GMT by default). If the browser timezone is different from the server timezone, the year value may differ.
MONTH
The MONTH function returns the month of the year as an integer.
Syntax
Sample
Remark
This function returns the month of the year as an integer between 1 and 12 (inclusive). Note that the month information retrieved is based on the timezone of the server (GMT by default). If the browser timezone is different from the server timezone, the month value may differ.
HOUR
The HOUR function returns the hour of the day as an integer.
Syntax
Sample
Remark
This function returns the hour of the day as an integer between 0 and 23 (inclusive). Hour information retrieved is based on a 24-hour clock & will be based on the timezone of the server (GMT by default). Note that, if browser timezone is different from the server timezone, the hour value may differ.