date

date, data type

The word date is a contextual keyword of the Envision language. It refers to the primitive data type date, which represents an integral date from January 1st, 2001 to June 6th, 2180. There are no date literals; use the date() function.

dd = date(2020, 8, 28)
show table "" write:"/sample/onedate.ion" with dd

followed by

read "/sample/onedate.ion" as T with
  dd : date

show scalar "" with same(T.dd)

date, dimension

The identifier date always refers to the primary dimension of the built-in Day table, and is always of type date.

date(year: number, month: number, dayOfMonth: number) -> date, const dash pure function

Returns the date associated to the specified year, month and dayOfMonth according to the Gregorian calendar.

show summary "" with
  date(2001, 1, 1)
  date(2020, 11, 25)
  date(2040, 6, 13)

The following restrictions apply, or the function fails:

date(month: month, dayOfMonth: number) -> date, const dash pure function

Returns the date associated with the specified day within month.

show summary "" with 
  date(month(2001, 1), 1)
  date(month(2020, 11), 25)
  date(month(2040, 6), 13)

date(week: week, dayOfWeek: number) -> date, const dash pure function

Returns the date associated with the specified day within week (monday is 1, sunday is 7).

show summary "" with 
  date(week(2001, 1), 1) // 2001-01-01
  date(week(2020, 48), 3) // 2020-11-25
  date(week(2040, 24), 3) // 2040-06-13

Date arithmetic

Adding or subtracting integers shifts dates by days. Subtracting two dates returns a number of days.

d1 = date(2021, 5, 21)
d2 = date(2021, 5, 20)

show summary "" with
  d1 + 1
  d1 - 2
  d1 - d2
User Contributed Notes
0 notes + add a note