Jorge Pradas
Jorge Pradas

Reputation: 93

How to convert a string to date with AM/PM?

I'm trying to convert a string to timestamp in Hive

String: 11/25/2014 07:58:37 AM

This command works but ignores the halfday of day:

select unix_timestamp(ClosedDate, 'MM/dd/yyyy HH:mm:ss') from ...

I tried this:

unix_timestamp(ClosedDate, 'MM/dd/yyyy HH:mm:ss a')

and this:

unix_timestamp(ClosedDate, 'MM/dd/yyyy HH:mm:ss tt')

but it doesn't work.

Upvotes: 1

Views: 7557

Answers (1)

Jorge Pradas
Jorge Pradas

Reputation: 93

the problem was in hour format.

    unix_timestamp(ClosedDate, 'MM/dd/yyyy hh:mm:ss a')

Upvotes: 6

Related Questions