← dateadd operator page · time/dateadd/comp/manual_ex_1
pandas ✅ · DuckDB ✅
dateadd(Me_1, 2, "M") inside calc: two months after each date.
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."
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.
DS_r:= DS_1[calc Me_2 := dateadd(Me_1, 2, "M")];
| Id_1 | Me_1 |
|---|---|
| G | 2019-01-01 |
| H | 2019-07-01 |
| T | 2020-12-31 |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "String", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Date", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| G | 2019-01-01 | 2019-03-01 |
| H | 2019-07-01 | 2019-09-01 |
| T | 2020-12-31 | 2021-02-28 |
{
"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"}
]
}
]
}