← cast operator page · general/cast/time_to_date/single_day_intervals

Single day intervals 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

cast(Me_1, date) on a Time measure whose intervals start and end on the same day, an explicit cast without mask.

Manual:

Type conversion: "From time to date: A date value is returned if the time value start and ends at the same date, otherwise an error is raised."

Expected:

2020-01-15 and 2021-12-31; neither raises the error.

script.vtl ⇩

DS_r := DS_1[calc Me_2 := cast(Me_1, date)];

input/DS_1.csv ⇩

Id_1Me_1
12020-01-15/2020-01-15
22021-12-31/2021-12-31

input/DS_1.json ⇩

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

expected/DS_r.csv ⇩

Id_1Me_1Me_2
12020-01-15/2020-01-152020-01-15
22021-12-31/2021-12-312021-12-31

expected/DS_r.json ⇩

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