doo.functions.date
The functions give you powerful tools to work with dates and times. They make it easy to create, change, and compare dates. With these functions, you can manage time-related information effectively, adapt it to your needs, and get useful data for your apps and tasks. Functions can also be used in the Calculated field type.
NEWDATE
Returns a Date instance parsed from the input parameter or a Date instance with current date-time if the input parameter is not passed. You can specify the time zone (e.g. Europe/Paris or UTC, respects DST, timeZone parameter is not supported in calculated fields). The default time zone is taken from the current application.
Example
doo.functions.date.newdate('2023-12-31T23:00:00Z') // returns Date with UTC time 2023-12-31 23:00:00; newdate('2024-01-01T00:00:00') (note there is no time zone specified in the date-time string) returns Date with UTC time 2023-12-31 23:00:00 for time zone Europe/Paris (GMT+1), but returns 2024-01-01 00:00:00 for time zone Europe/London (UTC/GMT+0)Tip:
When assigning a value to a model field of type date, always use a string in ISO format (e.g. 2024-01-01T00:00:00.000Z).
If you use doo.functions.date.newdate(...), remember to call .toISOString() before assigning the value:
const date = doo.functions.date.newdate('2024-01-01T00:00:00Z');
doo.model.date.value = date.toISOString();ADDINTERVAL
Add specified interval to the input value (Date/string -> returns the same datatype Date/string). The value can be either positive or negative. Supported intervals: milliseconds, seconds, minutes, hours, days, months, years.
Example
doo.functions.date.addInterval('2024-01-20T14:55:00', 'minutes', 2) // '2024-01-20T14:57:00'ADDDAYS
Add a number of days to the input value (Date/string -> returns the same datatype Date/string). The number of days can be either positive or negative.
Example
doo.functions.date.addDays('2024-01-20', -5) // '2024-01-15'ADDMONTHS
Use to add or subtract months from a date.
Example
doo.functions.date.addMonths('2024-01-20', 1) // '2024-02-20'ADDYEARS
Use to add or subtract years from a date.
Example
doo.functions.date.addYears('2024-01-20', -1) // '2023-01-20'MIN
Returns the lowest date.
Example
doo.functions.date.min('2021-01-01', '2022-01-01') // '2021-01-01'MAX
Returns the largest date.
Example
doo.functions.date.max('2021-01-01', '2022-01-01') // '2022-01-01'DIFF
unit - seconds, minutes, hours, days. months and years not supported. Returns number - float. Not integer (whole number)
Example
doo.functions.date.diff('2024-01-25', '2024-01-27', 'days') // 2
Returns part of the date. Year as a number. You can specify the time zone (e.g. Europe/Paris or UTC, respects DST, timeZone parameter is not supported in calculated fields). The default time zone is taken from the current application.YEAR
Returns part of the date. Year as a number. You can specify the time zone (e.g. Europe/Paris or UTC, respects DST, timeZone parameter is not supported in calculated fields). The default time zone is taken from the current application.
Example
doo.functions.date.year('2023-12-31T23:00:00Z') // returns 2024 for time zone Europe/Paris (GMT+1), but returns 2023 for time zone Europe/London (UTC/GMT+0) or America/New_York (GMT-5)MONTH
Returns part of the date. Month as a number. Ranging from 1 (January) to 12 (December). You can specify the time zone (e.g. Europe/Paris or UTC, respects DST, timeZone parameter is not supported in calculated fields). The default time zone is taken from the current application.
Example
doo.functions.date.month('2023-12-31T23:00:00Z') // returns 1 for time zone Europe/Paris (GMT+1), but returns 12 for time zone Europe/London (UTC/GMT+0) or America/New_York (GMT-5)WEEKISO
Returns part of the date. ISO week of the year as a number. Ranging from 1 (Sunday) to 7 (Saturday). You can specify the time zone (e.g. Europe/Paris or UTC, respects DST, timeZone parameter is not supported in calculated fields). The default time zone is taken from the current application.
Example
doo.functions.date.weekISO('2023-12-31T23:00:00Z') // returns 1 for time zone Europe/Paris (GMT+1), but returns 52 for time zone Europe/London (UTC/GMT+0) or America/New_York (GMT-5)DAY
Returns part of the date. Day 1-31 as a number. You can specify the time zone (e.g. Europe/Paris or UTC, respects DST, timeZone parameter is not supported in calculated fields). The default time zone is taken from the current application.
Example
doo.functions.date.day('2023-12-31T23:00:00Z') // returns 1 for time zone Europe/Paris (GMT+1), but returns 31 for time zone Europe/London (UTC/GMT+0) or America/New_York (GMT-5)HOUR
Returns part of the date. Hour 0-23 as a number. You can specify the time zone (e.g. Europe/Paris or UTC, respects DST, timeZone parameter is not supported in calculated fields). The default time zone is taken from the current application.
Example
doo.functions.date.hour('2023-12-31T23:00:00Z') // returns 0 for time zone Europe/Paris (GMT+1), but returns 23 for time zone Europe/London (UTC/GMT+0) and returns 18 for time zone America/New_York (GMT-5)MINUTE
Returns part of the date. Minutes 0-59 as a number. You can specify the time zone (e.g. Europe/Paris or UTC, respects DST, timeZone parameter is not supported in calculated fields). The default time zone is taken from the current application.
Example
doo.functions.date.minute('2023-12-31T23:00:00Z') // returns 0 for time zone Europe/Paris (GMT+1), but returns 30 for time zone Canada/Newfoundland (GMT-2:30) and returns 45 for time zone Australia/Eucla (GMT+8:45)WEEKDAY
Returns part of the date. Weekday as a number. Ranging from 1 (Sunday) to 7 (Saturday). You can specify the time zone (e.g. Europe/Paris or UTC, respects DST, timeZone parameter is not supported in calculated fields). The default time zone is taken from the current application.
Example
doo.functions.date.weekday('2023-12-31T23:00:00Z') // returns 2 for time zone Europe/Paris (GMT+1), but returns 1 for time zone Europe/London (UTC/GMT+0) or America/New_York (GMT-5)WEEKDAYISO
Returns part of the date. ISO day of the week as a number. Ranging from 1 (Monday) to 7 (Sunday). You can specify the time zone (e.g. Europe/Paris or UTC, respects DST, timeZone parameter is not supported in calculated fields). The default time zone is taken from the current application.
Example
doo.functions.date.weekdayISO('2023-12-31T23:00:00Z') // returns 1 for time zone Europe/Paris (GMT+1), but returns 7 for time zone Europe/London (UTC/GMT+0) or America/New_York (GMT-5)TODATESTRINGISO
Returns date-part only string in ISO format yyyy-MM-dd. You can specify the time zone (e.g. Europe/Paris or UTC, respects DST, timeZone parameter is not supported in calculated fields). The default time zone is taken from the current application.
Example
doo.functions.date.toDateStringISO('2023-12-31T23:00:00Z') // returns '2024-01-01' for time zone Europe/Paris (GMT+1), but returns '2023-12-31' for time zone Europe/London (UTC/GMT+0) or America/New_York (GMT-5)TODATESTRINGAPP
Returns date-part only string in format specified in the current application. You can specify the time zone (e.g. Europe/Paris or UTC, respects DST, timeZone parameter is not supported in calculated fields). The default time zone is taken from the current application.
Example
doo.functions.date.toDateStringApp('2023-12-31T23:00:00Z') (app. format 'dd.MM.yyyy') // returns '01.01.2024' for time zone Europe/Paris (GMT+1), but returns '31.12.2023' for time zone Europe/London (UTC/GMT+0) or America/New_York (GMT-5)TODATETIMESTRINGAPP
Returns date-time string in format specified in the current application. You can specify the time zone (e.g. Europe/Paris or UTC, respects DST, timeZone parameter is not supported in calculated fields). The default time zone is taken from the current application.
Example
doo.functions.date.toDateTimeStringApp('2023-12-31T23:00:00Z') (app. format 'dd.MM.yyyy' and 24h time) // returns '01.01.2024 00:00' for time zone Europe/Paris (GMT+1), but returns '31.12.2023 19:30' for time zone Canada/Newfoundland (GMT-2:30) and returns '01.01.2024 07:45' for time zone Australia/Eucla (GMT+8:45)