month
month, function
def const dash pure month(y: number, m: number): month
def const dash pure month(d: date): month
Returns a month value built from year and month number, or extracted from
d.
y: year.m: month number (1 to 12).d: input date.
Examples
table T = with
[| as Year, as Month |]
[| 2020, 10 |]
[| 2021, 1 |]
T.M = month(T.Year, T.Month)
show table "Month from numbers" with
T.Year
T.Month
T.M
This produces the following table:
| Year | Month | M |
|---|---|---|
| 2020 | 10 | 2020-10 |
| 2021 | 1 | 2021-01 |
table T = with
[| as D |]
[| date(2019, 12, 28) |]
[| date(2020, 1, 1) |]
show table "Month from date" with
T.D
month(T.D) as "M"
This produces the following table:
| D | M |
|---|---|
| 2019-12-28 | 2019-12 |
| 2020-01-01 | 2020-01 |
Remarks
month is a primitive data type with arithmetic in months. The special calendar
table Month[month] is created via expect [date] or span date =, and any
table with a date dimension also gains a month secondary dimension.