psobhan
psobhan

Reputation: 645

How to convert date to GMT format using oracle

I want to convert my user selected date into GMT format and store in DB.

Query:

select cast('7/1/2015 12:00:00 AM' as timestamp) AT TIME ZONE 'GMT' from dual

The following error is thrown:

ORA-01843: not a valid month
01843. 00000 -  "not a valid month"

The query works fine when month is mentioned as Jan. But I dont find any GMT conversion in it.Similarly how to change the month to MMM without changing the hh:mm:ss. Kindly help

Upvotes: 0

Views: 7852

Answers (1)

Petr Pribyl
Petr Pribyl

Reputation: 3575

Try

select cast(to_date('7/1/2015 12:00:00 AM','mm/dd/yyyy hh:mi:ss AM') as timestamp) AT TIME ZONE 'GMT' from dual

Upvotes: 3

Related Questions