hive TIMESTAMPDIFF
时间: 2023-10-18 12:28:42 浏览: 120
Hive's TIMESTAMPDIFF function is used to calculate the difference between two given timestamps in a specified unit. The function syntax is as follows:
```
TIMESTAMPDIFF(unit, timestamp1, timestamp2)
```
Here, `unit` is a string that represents the desired unit of measurement for the difference, such as "SECOND", "MINUTE", "HOUR", "DAY", "MONTH", or "YEAR". `timestamp1` and `timestamp2` are the two timestamps between which you want to calculate the difference.
For example, if you want to calculate the difference in days between two timestamps, you can use the following query:
```
SELECT TIMESTAMPDIFF(DAY, '2022-01-01 00:00:00', '2022-01-05 12:00:00');
```
This will return the result as 5, which is the number of days between the two given timestamps.
阅读全文