← dayofyear operator page · time/dayofyear/comp/leap_and_common_years

Leap and common years 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

dayofyear(Me_1) inside calc, on March 1st of a common and of a leap year, and on the last day of a leap year.

Manual:

Extract time period: "The operator dayofyear returns the ordinal day within the year (between 1 and 366)."

Expected:

Me_2 is 60 (31 + 28 + 1, in 2019), 61 (31 + 29 + 1, in 2020) and 366, Integers.

script.vtl ⇩

DS_r := DS_1[calc Me_2 := dayofyear(Me_1)];

input/DS_1.csv ⇩

Id_1Me_1
G2019-03-01
H2020-03-01
T2020-12-31

input/DS_1.json ⇩

{
  "datasets": [
    {
      "name": "DS_1",
      "DataStructure": [
        {"name": "Id_1", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Date", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Me_1Me_2
G2019-03-0160
H2020-03-0161
T2020-12-31366

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "String", "role": "Identifier"},
        {"name": "Me_1", "type": "Date", "role": "Measure"},
        {"name": "Me_2", "type": "Integer", "role": "Measure"}
      ]
    }
  ]
}