← cast operator page · general/cast/date_to_time_period/daily_periods
pandas ✅ · DuckDB ✅
cast(Me_1, time_period) on a Date measure, an explicit cast without mask.
Type conversion: "From date to time_period: A time_period value with a daily duration is returned, starting and ending at the specified date value."
Daily periods, written YYYYD and the day of the year: 2020D15, 2020D61 for March 1st, after the 31 days of January and the 29 of February, and 2021D365, 2021 not being a leap year.
DS_r := DS_1[calc Me_2 := cast(Me_1, time_period)];
| Id_1 | Me_1 |
|---|---|
| 1 | 2020-01-15 |
| 2 | 2020-03-01 |
| 3 | 2021-12-31 |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Date", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| 1 | 2020-01-15 | 2020D15 |
| 2 | 2020-03-01 | 2020D61 |
| 3 | 2021-12-31 | 2021D365 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Me_1", "type": "Date", "role": "Measure"},
{"name": "Me_2", "type": "Time_Period", "role": "Measure"}
]
}
]
}