← getyear operator page · time/getyear/comp/dates_of_three_years

Dates of three years 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

getyear(Me_1) inside calc, on dates of 2018, 2019 and 2020.

Manual:

Extract time period: "The operator getyear returns the year of the given date/time period", and "In the component version, that can be used in a calc clause, a new component of type integer is added to the dataset."

Expected:

Me_2 is 2018, 2019 and 2020, Integers.

script.vtl ⇩

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

input/DS_1.csv ⇩

Id_1Me_1
G2018-06-30
H2019-01-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
G2018-06-302018
H2019-01-012019
T2020-12-312020

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"}
      ]
    }
  ]
}