Skip to content
Advertisement

Time zone conversion in SQL query

I am using a query to get some application Received Date from Oracle DB which is stored as GMT. Now I have to convert this to Eastern standard/daylight savings time while retrieving. I am using the below query for this:

It works fine for Standard time. But for daylight savings time we need to convert it to ‘edt’ based on timezone info. I am not very sure on how to do this. Please help me out

Advertisement

Answer

You can use this query, without having to worry about timezone changes.

Ex:

EDT:

EST:

UPDATE:

Thanks to Alex Poole for reminding that, when timezone is not specified, local timezone is used for conversion.

To force the date to be recognized as GMT, use from_tz.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement