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

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

dateadd(Me_1, 2, "M") inside calc: two months after each date.

Manual:

Add time unit to date, Example 1, output verbatim: "adding months to a given date returns the date plus integer months", and "In the component version, that can be used in a calc clause, a new component of type date is added to the dataset."

Expected:

Me_2 is 2019-03-01, 2019-09-01 and 2021-02-28, two months after 2020-12-31 being the last day of February 2021.

script.vtl ⇩

DS_r:= DS_1[calc Me_2 := dateadd(Me_1, 2, "M")];

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-012019-03-01
H2019-07-012019-09-01
T2020-12-312021-02-28

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": "Date", "role": "Measure"}
      ]
    }
  ]
}