← cast operator page · general/cast/time_period_to_date/daily_periods
pandas ✅ · DuckDB ✅
cast(Me_1, date) on a Time_Period measure of daily periods, an explicit cast without mask.
Type conversion: "From time_period to date: A date value is returned if the input time_period has a duration of a single day, representing that day; otherwise an error is raised."
2020D15 gives 2020-01-15 and 2020D61 gives 2020-03-01, 2020 being a leap year; both are daily, so neither raises the error.
DS_r := DS_1[calc Me_2 := cast(Me_1, date)];
| Id_1 | Me_1 |
|---|---|
| 1 | 2020D15 |
| 2 | 2020D61 |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Time_Period", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| 1 | 2020D15 | 2020-01-15 |
| 2 | 2020D61 | 2020-03-01 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Me_1", "type": "Time_Period", "role": "Measure"},
{"name": "Me_2", "type": "Date", "role": "Measure"}
]
}
]
}