📅  最后修改于: 2023-12-03 15:01:06.451000             🧑  作者: Mango
HANA数据库是一种非常强大的数据库解决方案。HANA提供了许多内置函数,这些函数可以执行各种操作,包括操作日期和时间。在HANA中,可以使用'hana date add'函数来添加或减去日期或时间值。
SELECT ADD_DAYS(date, days),
ADD_MONTHS(date, months),
ADD_SECONDS(time, seconds),
ADD_MINUTES(time, minutes),
ADD_HOURS(time, hours)
FROM table;
SELECT ADD_DAYS('2021-01-01', 7) as New_Date FROM DUMMY;
输出结果:
| New_Date | | ---------- | | 2021-01-08 |
SELECT ADD_DAYS('2021-01-01', -7) as New_Date FROM DUMMY;
输出结果:
| New_Date | | ---------- | | 2020-12-25 |
SELECT ADD_MONTHS('2021-01-01', 2) as New_Date FROM DUMMY;
输出结果:
| New_Date | | ---------- | | 2021-03-01 |
SELECT ADD_MONTHS('2021-01-01', -2) as New_Date FROM DUMMY;
输出结果:
| New_Date | | ---------- | | 2020-11-01 |
SELECT ADD_SECONDS('14:02:30', 10) as New_Time FROM DUMMY;
输出结果:
| New_Time | | ---------- | | 14:02:40 |
SELECT ADD_SECONDS('14:02:30', -10) as New_Time FROM DUMMY;
输出结果:
| New_Time | | ---------- | | 14:02:20 |