Columnal Documentation: Table of Contents

datetime functions

date from ymdtime from hmstime from datetimetime from datetimezoneddate from datetimedate from datetimezoneddatetime from datetimezoneddateym from ymdateym from datedatetime from dtdatetimezoned from dtzyears betweendays betweenadd daysseconds between
date from ymd(year, month, day)date Type: (Number{year}, Number{month}, Number{day}) -> Date

Creates a date from the given year, month and day.

Months and days start at 1: 1{month} is January, and 1{day} is the first day of the month.

ExamplesClick an example to insert it
date from ymd(1998{year}, 07{month}, 10{day})date{1998-07-10}
date from ymd(2004{year}, 08{month}, 06{day})from text("6 August 2004")
time from hms(hour, minute, second)time Type: (Number{hour}, Number{minute}, Number{s}) -> Time

Creates a time-of-day (or clock time) from the given hours, minutes and seconds.

ExamplesClick an example to insert it
time from hms(13{hour}, 31{minute}, 0{s})time{13:31:00}
time from datetime(datetime)time Type: (DateTime) -> Time

Gets the Time part of a DateTime.

ExamplesClick an example to insert it
time from datetime(datetime{2001-03-04 06:54})time{06:54}
time from datetimezoned(datetimezoned)time Type: (DateTimeZoned) -> Time

Gets the Time part of a DateTimeZoned.

No timezone conversions are performed, this just takes the time part, ignoring the date and the zone.

ExamplesClick an example to insert it
time from datetimezoned(datetimezoned{2001-03-04 06:54 UTC})from text("06:54")
date from datetime(datetime)date Type: (DateTime) -> Date

Gets the Date part of a DateTime.

ExamplesClick an example to insert it
date from datetime(datetime{2001-03-04 06:54})date{2001-03-04}
date from datetimezoned(datetimezoned)date Type: (DateTimeZoned) -> Date

Gets the Date part of a DateTimeZoned.

No timezone conversions are performed, this just takes the time part, ignoring the date and the zone.

ExamplesClick an example to insert it
date from datetimezoned(datetimezoned{2001-03-04 06:54 UTC})date{2001-03-04}
datetime from datetimezoned(datetimezoned)datetime Type: (DateTimeZoned) -> DateTime

Gets the DateTime part of a DateTimeZoned.

No timezone conversions are performed, this just takes the DateTime part, ignoring the zone.

ExamplesClick an example to insert it
datetime from datetimezoned(datetimezoned{2001-03-04 06:54 UTC})datetime{2001-03-04 06:54}
dateym from ym(year, month)dateym Type: (Number{year}, Number{month}) -> DateYM

Creates a year-month value from the given year and month.

ExamplesClick an example to insert it
dateym from ym(1998{year}, 07{month})dateym{1998-07}
dateym from ym(2004{year}, 08{month})dateym{2004-08}
dateym from date(date)dateym Type: (Date) -> DateYM

Gets the year and month part of a Date as a DateYM.

ExamplesClick an example to insert it
dateym from date(from text("2001-03-04"))from text("2001-03")
datetime from dt(date, time)datetime Type: (Date, Time) -> DateTime

Creates a DateTime from the given Date and Time.

ExamplesClick an example to insert it
datetime from dt(from text("2001-02-03"), from text("04:56"))from text("2001-02-03 04:56")
datetimezoned from dtz(date, time, zone)datetimezoned Type: (Date, Time, Text) -> DateTimeZoned

Creates a datetime with a time zone from the given Date, Time and time zone.

Note that because many of the three-letter abbreviations for time zones overlap, they are not supported here, and you must spell out the full name.

ExamplesClick an example to insert it
datetimezoned from dtz(from text("2001-02-03"), from text("04:56"), "America/Vancouver")from text("2001-02-03 04:56 America/Vancouver")
years between(start, end)days Type: (Date, Date) -> Number{year}

Calculates the number of years between two dates.

If the first date is before the second date, the returned number is positive. If the first date is after the second date, the returned number will be negative.

ExamplesClick an example to insert it
years between(date{4 April 1999}, date{4 April 2000})1{year}
years between(date{4 April 1999}, date{5 April 2000})1{year} + (1{year}/365)
years between(date{4 February 1999}, date{5 February 2000})1{year} + (1{year}/366)
days between(start, end)days Type: (Date, Date) -> Number{day}

Calculates the number of days between two dates.

If the first date is before the second date, the returned number is positive. If the first date is after the second date, the returned number will be negative.

ExamplesClick an example to insert it
days between(from text("7 May 2003"), from text("16 October 2004"))528{day}
add days(date, days to add)result date Type: (Date, Number{day}) -> Date

Adds the given number of the days to the date.

ExamplesClick an example to insert it
add days(date{2002-11-01}, 28{day})date{2002-11-29}
add days(date{2000-01-01}, 0.5{day})error
seconds between(start, end)seconds Type: (Time, Time) -> Number{s}

Calculates the number of seconds between two times.

If the first time is before the second time, the returned number is positive. If the first time is after the second time, the returned number will be negative.

This function does not consider wrap-around. That is, 00:30 is considered to be 23 hours before 23:30, not one hour after.

ExamplesClick an example to insert it
seconds between(time{00:05:08}, time{00:05:29})21{s}