Date
Mar 06, 2023 • 3 minutes to readDate modification operators and static dates including timestamp and date difference.
Date
Static value for a date. It can be used, for example, to set a fixed billing date for all customers, ensuring that invoices are generated consistently on the same day each month.
Timestamp
Timestamp returns a date/time value in a given timezone based on a date and time values from the moment a trigger is executed.
Get date/time part from a date
Get date/time part from a date returns a specific part of a date.
The following options are available:
- Year – returns a year of a date/time value. For example, the year value for 2020/09/15 is 2020.
- Quarter – returns the quarter of the year for a date. For example, the quarter value for 2020-04-22 is 2.
- Month – returns a month for a date/time value. For example, the month value for 2020/09/15 is 9.
- Day of year – returns the day of the year for a date. For example, the day of the year for 2020-02-02 is 32.
- Day – returns the day of the month for a date. For example, the day value for 2020/05/16 is 16.
- Week – returns the week number for a date/time value. For example, the week value for 2020-03-15 is 11.
- Weekday – returns the weekday number for a date: 1 = Sunday, 2 = Monday, 3 = Tuesday, 4 = Wednesday, 5 = Thursday, 6 = Friday, 7 = Saturday. For example, the weekday for 2020-03-20 is 6.
- Hour – returns an hour for a date/time value. For example, the hour value for 2020/09/15 9:50 is 9.
- Minute – returns a minute value for a date/time value. For example, the minute value for 2020/09/15 9:50 is 50.
- Second – returns the second part of a date/time value. For example, the second value for 2020-03-18 09:42:05.000024 is 5.
- Millisecond – returns the millisecond part of a date/time value. For example, the millisecond value of 2020-03-18 09:42:05.02445345 is 24.
Date addition
It adds an integer number to a date to calculate a new date by adding a given number of days, months, or years.
For example, it can be used to generate a target completion date, helping users to plan their work effectively and ensuring that important tasks are completed on time.
Date difference
It calculates the difference in a date or time between two dates. If the right argument date is a past date, the returned value is negative. If the date is in the future, the returned value is positive. Date difference returns an integer number.
For example, it can calculate the time since a customer’s last interaction with the company, comparing the date of their last engagement with the current date.