- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Format date in HIVE
- Labels:
-
Apache Hive
Created 09-27-2018 03:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, how do you format date like this in HIVE ?
from:
Tue Sep 26 22:02:11 CDT 2018
to:
2018-09-26 22:02:11
I've tried different format specifier but didn't work. I must have done something wrong. Any help would be helpful. Thanks
Created 09-27-2018 01:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To change the format of the input time we need to use unix_timestamp along with from_unixtime funcitons.
Try with below syntax
hive> select from_unixtime(unix_timestamp("Tue Sep 26 22:02:11 CDT 2018",'EEE MMM dd HH:mm:ss z yyyy'),'yyyy-MM-dd HH:mm:ss'); +----------------------+--+ | _c0 | +----------------------+--+ | 2018-09-26 22:02:11 | +----------------------+--+
-
If the Answer helped to resolve your issue, Click on Accept button below to accept the answer, That would be great help to Community users to find solution quickly for these kind of issues.
Created 09-27-2018 01:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To change the format of the input time we need to use unix_timestamp along with from_unixtime funcitons.
Try with below syntax
hive> select from_unixtime(unix_timestamp("Tue Sep 26 22:02:11 CDT 2018",'EEE MMM dd HH:mm:ss z yyyy'),'yyyy-MM-dd HH:mm:ss'); +----------------------+--+ | _c0 | +----------------------+--+ | 2018-09-26 22:02:11 | +----------------------+--+
-
If the Answer helped to resolve your issue, Click on Accept button below to accept the answer, That would be great help to Community users to find solution quickly for these kind of issues.
