Integromat
  • Back to website
Articles in this section
  • Using Functions
  • General Functions
  • String Functions
  • Math Functions
  • Date & Time Functions
  • Array Functions
  • Tokens for date/time formatting
  • Tokens for date/time parsing
  1. Integromat Support
  2. Using Integromat
  3. Functions

Date & Time Functions

Patrik Šimek Patrik Šimek Updated February 11, 2019 12:01

addDays (date; number)

Returns a new date as a result of adding a given number of days to a date. To subtract days, enter a negative number.

addDays(2016-12-08T15:55:57.536Z;2)
= 2016-12-10T15:55:57.536Z
addDays(2016-12-08T15:55:57.536Z;-2)
= 2016-12-6T15:55:57.536Z

addHours (date; number)

Returns a new date as a result of adding a given number of hours to a date. To subtract hours, enter a negative number.

addHours(2016-12-08T15:55:57.536Z;2)
= 2016-12-08T17:55:57.536Z
addHours(2016-12-08T15:55:57.536Z;-2)
= 2016-12-08T13:55:57.536Z

addMinutes (date; number)

Returns a new date as a result of adding a given number of minutes to a date. To subtract minutes, enter a negative number.

addMinutes(2016-12-08T15:55:57.536Z;2)
= 2016-12-08T15:57:57.536Z
addMinutes(2016-12-08T15:55:57.536Z;-2)
= 2016-12-08T15:53:57.536Z

addMonths (date; number)

Returns a new date as a result of adding a given number of months to a date. To subtract months, enter a negative number.

addMonths(2016-08-08T15:55:57.536Z;2)
= 2016-12-10T15:55:57.536Z
addMonths(2016-08-08T15:55:57.536Z;-2)
= 2016-12-06T15:55:57.536Z

addSeconds (date; number)

Returns a new date as a result of adding a given number of seconds to a date. To subtract seconds, enter a negative number.

addSeconds(2016-12-08T15:55:57.536Z;2)
= 2016-12-08T15:55:59.536Z
addSeconds(2016-12-08T15:55:57.536Z;-2)
= 2016-12-08T15:55:55.536Z

addYears (datum;years)

Returns a new date as a result of adding a given number of years to a date. To subtract years, enter a negative number.

addYears(2016-08-08T15:55:57.536Z;2)
= 2018-08-08T15:55:57.536Z
addYears(2016-08-08T15:55:57.536Z;-2)
= 2014-08-08T15:55:57.536Z

formatDate (date; format; [timezone])

Returns a date in the requested format and optionally, in a specified timezone. For example, format DD.MM.YYYY HH:mm. See the list of supported timezones.

formatDate(2016-12-28T16:03:06.372Z;MM/DD/YYYY)
= 12/28/2016
formatDate(2016-12-28T16:03:06.372Z;YYYY-MM-DD hh:mm A)
= 2016-12-28 4:03 PM
formatDate(2016-12-28T16:03:06.372Z;DD.MM.YYYY HH:mm;Europe/Prague)
= 28.12.2016 17:03

parseDate (date; format; [timezone])

Parses a string with a date and returns the date.

parseDate(2016-12-28;YYYY-MM-DD)
= 2016-12-28T00:00:00.000Z
parseDate(2016-12-28 16:03;YYYY-MM-DD HH:mm)
= 2016-12-28T16:03:00.000Z
parseDate(2016-12-28 04:03 pm;YYYY-MM-DD hh:mm a)
= 2016-12-28T16:03:06.000Z
parseDate(1482940986;X)
= 2016-12-28T16:03:06.000Z

setSecond (date; number)

Returns a new date with the seconds specified in parameters. Accepts numbers from 0 to 59. If a number is given outside of this range, it will return the date with the seconds from the previous or subsequent minute(s), accordingly.

setSecond(2015-10-07T11:36:39.138Z;10)
= 2015-10-07T11:36:10.138Z
setSecond(2015-10-07T11:36:39.138Z;61)
= 2015-10-07T11:37:01.138Z

setMinute (date; number)

Returns a new date with the minutes specified in parameters. Accepts numbers from 0 to 59. If a number is given outside of the range, it will return the date with the minutes from the previous or subsequent hour(s), accordingly.

setMinute(2015-10-07T11:36:39.138Z;10)
= 2015-10-07T11:10:39.138Z
setMinute(2015-10-07T11:36:39.138Z;61)
= 2015-10-07T12:01:39.138Z

setHour (date; number)

Returns a new date with the hour specified in parameters. Accepts numbers from 0 to 23. If a number is given outside of the range, it will return the date with the hour from the previous or subsequent day(s), accordingly.

setHour(2015-08-07T11:36:39.138Z;6)
= 2015-08-07T04:36:39.138Z
setHour(2015-08-07T11:36:39.138Z;-6)
= 2015-08-06T16:36:39.138Z

setDay (date; number/name of the day in english)

Returns a new date with the day specified in parameters. It can be used to set the day of the week, with Sunday as 1 and Saturday as 7. If the given value is from 1 to 7, the resulting date will be within the current (Sunday-to-Saturday) week. If a number is given outside of the range, it will return the day from the previous or subsequent week(s), accordingly.

setDay(2018-06-27T11:36:39.138Z;monday)
= 2018-06-25T11:36:39.138Z
setDay(2018-06-27T11:36:39.138Z;1)
= 2018-06-24T11:36:39.138Z
setDay(2018-06-27T11:36:39.138Z;7)
= 2018-06-30T11:36:39.138Z

setDate (date; number)

Returns a new date with the day of the month specified in parameters. Accepts numbers from 1 to 31. If a number is given outside of the range, it will return the day from the previous or subsequent month(s), accordingly.

setDate(2015-08-07T11:36:39.138Z;5)
= 2015-08-05T11:36:39.138Z
setDate(2015-08-07T11:36:39.138Z;32)
= 2015-09-01T11:36:39.138Z

setMonth (date; number/name of the month in English)

Returns a new date with the month specified in parameters. Accepts numbers from 1 to 12. If a number is given outside of this range, it will return the month in the previous or subsequent year(s), accordingly.

setMonth(2015-08-07T11:36:39.138Z;5)
= 2015-05-07T11:36:39.138Z
setMonth(2015-08-07T11:36:39.138Z;17)
= 2016-05-07T11:36:39.138Z
setMonth(2015-08-07T11:36:39.138Z;january)
= 2015-01-07T12:36:39.138Z

setYear (date; number)

Returns a new date with the year specified in parameters.

setYear(2015-08-07T11:36:39.138Z;2017)
= 2017-08-07T11:36:39.138Z

 

Examples

How to calculate days between dates

One possibility is to employ the following expression:

​

You can copy & paste the following code:

{{round((2.value - 1.value) / 1000 / 60 / 60 / 24)}}

NOTE: Values of D1 and D2 have to be of type Date. If they are of type String (e.g. "20.10.2018"), use parseDate() function to convert them to type Date.

INFO: The round() function is used for cases when one of the dates falls within the daylight savings time period and the other not. In these cases, the difference in hours is by one hour less/more and dividing it by 24 gives a non-integer results.

Was this article helpful?
10 out of 16 found this helpful
Menu
  • Features
  • Apps & Services
  • Templates
  • Pricing
  • What's new
  • Use cases
Information
  • Terms,  Privacy
  • FAQ
  • Help & Tutorials
  • Community
  • Affiliate Program
  • Blog
Developers
  • Developer Platform
Company
  • About the company
  • We are hiring
  • Contact
Follow us
© 2018 Integromat. All rights reserved. Integromat® is a registered trademark.
  • English