yearStart

yearStart, function

def const pure yearStart(d: date): date
def const pure yearStart(m: month): date

Returns the first day of the Gregorian year for a date or month.

Example (date input)

table D = with
  [| as Label, as D |]
  [| "2020-01-01", date(2020, 1, 1) |]
  [| "2019-05-01", date(2019, 5, 1) |]

show table "Year start (date)" with
  D.Label
  yearStart(D.D) as "YearStart"

This outputs the following table:

Label YearStart
2020-01-01 2020-01-01
2019-05-01 2019-01-01

Example (month input)

table M = with
  [| as Label, as M |]
  [| "2022-01", month(2022, 1) |]
  [| "2022-12", month(2022, 12) |]

show table "Year start (month)" with
  M.Label
  yearStart(M.M) as "YearStart"

This outputs the following table:

Label YearStart
2022-01 2022-01-01
2022-12 2022-01-01

See also

User Contributed Notes
0 notes + add a note