← dateadd operator page · time/dateadd/ds/shifts_the_time_identifier

Shifts the time identifier 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

dateadd(DS_1, 1, "M"), the page's valid syntax DS_r := dateadd(DS_1, 1, “M”), on a dataset whose one time component is the date identifier Id_2.

Manual:

Add time unit to date: the operand is dataset{ identifier < time > _ , identifier _* }, and "the result Data Set has the same Identifier, Measure and Attribute Components as the operand Data Set". The type names no time measure, only the time identifier, so Id_2 moves and Me_1 is kept; the page does not say it in words, and DS_1 allows no other reading.

Expected:

One month later, keeping the day as "dateadd (2020-02-10, 1, “M”) gives 2020-03-10": 2019-02-15 and 2020-03-10, every component keeping its type.

script.vtl ⇩

DS_r := dateadd(DS_1, 1, "M");

input/DS_1.csv ⇩

Id_1Id_2Me_1
A2019-01-1510
B2020-02-1020

input/DS_1.json ⇩

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

expected/DS_r.csv ⇩

Id_1Id_2Me_1
A2019-02-1510
B2020-03-1020

expected/DS_r.json ⇩

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