hive FROM_UNIXTIME
时间: 2023-11-03 22:55:48 浏览: 196
Hive provides the `FROM_UNIXTIME` function to convert a UNIX timestamp (in seconds) to a string representing the corresponding date and time. The syntax for using `FROM_UNIXTIME` in Hive is as follows:
```
SELECT FROM_UNIXTIME(unix_timestamp) AS formatted_date
FROM your_table;
```
Here, `unix_timestamp` is the column or expression representing the UNIX timestamp you want to convert. `formatted_date` is an optional alias for the resulting formatted date string.
For example, if you have a table named `your_table` with a column `timestamp_col` containing UNIX timestamps, you can use the following query to convert them to formatted dates:
```
SELECT FROM_UNIXTIME(timestamp_col) AS formatted_date
FROM your_table;
```
This will return a result set with the formatted dates corresponding to the UNIX timestamps.
阅读全文