hql date_sub
时间: 2023-09-20 15:11:25 浏览: 84
HQL (Hive Query Language) provides the `date_sub` function, which is used to subtract a specified number of days from a given date.
The syntax for the `date_sub` function in HQL is as follows:
```
date_sub(date, num_days)
```
Here, `date` is the input date from which you want to subtract days, and `num_days` is the number of days you want to subtract.
For example, to subtract 7 days from the current date, you can use the following query:
```
SELECT date_sub(current_date(), 7);
```
This will return a date that is 7 days before the current date.
Note that the `date_sub` function only works with dates and not with timestamps. If you need to subtract days from a timestamp, you can extract the date part using the `date` function and then use `date_sub`.
阅读全文