Reputation: 15564
I have some scv input data files, which look like this:
TicketID,AccountID,DateOpened
1,acc-1,2015-10-29 T 10:45 UTC
2,acc-2,2015-10-29 T 10:45 UTC
3,acc-1,2015-10-30 T 10:45 UTC
Is there a way to have Hive parse the DateOpened field as a Date?
Upvotes: 0
Views: 2213
Reputation: 2691
Try simple and very handy TO_DATE
select TO_DATE(DateOpened) from tablename;
output:-
2015-10-29
2015-10-29
2015-10-30
Upvotes: 1
Reputation: 2964
You can use a substr function to grab the date from your timestamp and then cast it as a date data type.
select cast(substr(DateOpened,1,10) as date) from yourTableName
Upvotes: 1