Skip to main content

Date

Library of functions for the date type.

Functions

AddInterval

Adds an interval to a date.

Syntax:
Date.AddInterval(date: date, interval: interval)
Parameters
  • date: Start date.
  • interval: interval to add.
Example:
let
d = Date.Build(2018, 1, 1),
i = Interval.Build(years = 1, months = 2, days = 3, hours = 9, minutes = 30)
in
Date.AddInterval(d, i) // 2019-03-04 09:30

Build

Builds a date value.

Syntax:
Date.Build(year: int, month: int, day: int)
Parameters
  • year: Year component of the date to build.
  • month: Month component of the date to build.
  • day: Day component of the date to build.
Example:
Date.Build(2022, 1, 15) // 15th January 2022

Day

Returns the day component of the date.

Syntax:
Date.Day(date: date)
Parameters
  • date: The date from which the day component is extracted.
Example:
Date.Day(Date.Build(1975, 6, 23)) // 23

FromEpochDay

Builds a date by adding the number of days from 1970-01-01 (Unix epoch).

Syntax:
Date.FromEpochDay(epochDays: long)
Parameters
  • epochDays: The number of days since 1970-01-01 (Unix epoch).
Example:
Date.FromEpochDay(0) // 1970-01-01
Date.FromEpochDay(1000) // 1972-09-27

FromTimestamp

Builds a date from a timestamp.

Syntax:
Date.FromTimestamp(timestamp: timestamp)
Parameters
  • timestamp: The timestamp to convert to date.
Example:
Date.FromTimestamp(Timestamp.Build(1975, 6, 23, 9, 30)) // 1975-06-23

Month

Returns the month component of the date.

Syntax:
Date.Month(date: date)
Parameters
  • date: The date from which the month component is extracted.
Example:
Date.Month(Date.Build(1975, 6, 23)) // 6

Now

Returns the current date.

Syntax:
Date.Now()

Parse

Parses a date from a string.

Syntax:
Date.Parse(value: string, format: string)
Parameters
  • value: The string to convert to date.
  • format: The format of the date.
Example:
Date.Parse("2018-02-01", "yyyy-MM-dd") // 2018-02-01
Date.Parse("23 June 1975", "d MMMM yyyy") // 1975-06-23

Details

For more information about format strings see the Temporal templates documentation.

Subtract

Subtracts two dates.

Syntax:
Date.Subtract(date1: date, date2: date)
Parameters
  • date1: date to be subtracted (minuend).
  • date2: date to subtract (subtrahend).
Example:
let
d1 = Date.Build(2019, 3, 4),
d2 = Date.Build(2018, 1, 1)
in
Date.Subtract(d1, d2) // interval: years=1, months=2, days=3

SubtractInterval

Subtracts an interval to a date.

Syntax:
Date.SubtractInterval(date: date, interval: interval)
Parameters
  • date: Start date.
  • interval: Interval to subtract.
Example:
let
d = Date.Build(2019, 3, 4),
i = Interval.Build(years = 1, months = 2, days = 3, hours = 9, minutes = 30)
in
Date.SubtractInterval(d, i) // 2018-01-01 00:00

Year

Returns the year component of the date.

Syntax:
Date.Year(date: date)
Parameters
  • date: The date from which the year component is extracted.
Example:
Date.Year(Date.Build(1975, 6, 23)) // 1975