← getmonth operator page · time/getmonth/comp/manual_ex_1

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

getmonth(Me_1) inside calc, on three dates.

Manual:

Extract time period, Example 1, output verbatim: "The operator getmonth returns the month of the given date/time period (between 1 and 12)."

Expected:

Me_2 is 1, 7 and 12, Integers.

script.vtl ⇩

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

input/DS_1.csv ⇩

Id_1Me_1
G2019-01-01
H2019-07-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-01-011
H2019-07-017
T2020-12-3112

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