datetime_add()
Calculates a new datetime from a specified period multiplied by a specified amount, added to a specified datetime.
Syntax
datetime_add(period,amount,datetime)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| period | string | ✓ | The length of time by which to increment. |
| amount | int | ✓ | The number of periods to add to datetime. |
| datetime | datetime | ✓ | The date to increment by the result of the period x amount calculation. |
Possible values of period:
- Year
- Quarter
- Month
- Week
- Day
- Hour
- Minute
- Second
- Millisecond
- Microsecond
- Nanosecond
Returns
A date after a certain time/date interval has been added.
Examples
print year = datetime_add('year',1,make_datetime(2023,1,1)),
quarter = datetime_add('quarter',1,make_datetime(2023,1,1)),
month = datetime_add('month',1,make_datetime(2023,1,1)),
week = datetime_add('week',1,make_datetime(2023,1,1)),
day = datetime_add('day',1,make_datetime(2023,1,1)),
hour = datetime_add('hour',1,make_datetime(2023,1,1)),
minute = datetime_add('minute',1,make_datetime(2023,1,1)),
second = datetime_add('second',1,make_datetime(2023,1,1))
Returns
| year | quarter | month | week | day | hour | minute | second |
|---|---|---|---|---|---|---|---|
| 2024-01-01T00:00:00.000Z | 2023-04-01T00:00:00.000Z | 2023-02-01T00:00:00.000Z | 2023-01-08T00:00:00.000Z | 2023-01-02T00:00:00.000Z | 2023-01-01T01:00:00.000Z | 2023-01-01T00:01:00.000Z | 2023-01-01T00:00:01.000Z |