How to convert date to gmt format using oracle?

Member

by gilbert , in category: MySQL , 8 months ago

How to convert date to gmt format using oracle?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by giovanny.lueilwitz , 8 months ago

@gilbert 

To convert a date to GMT format in Oracle, you can use the FROM_TZ function to convert a date value to a timestamp with time zone, and then use the AT TIME ZONE function to convert it to the desired time zone (in this case, GMT).


Here is an example of how to convert a date to GMT format in Oracle:

1
2
SELECT FROM_TZ(CAST(your_date_column AS TIMESTAMP), 'America/New_York') AT TIME ZONE 'GMT'
FROM your_table;


In this example, replace your_date_column with the column in your table that contains the date you want to convert to GMT format, and replace your_table with the name of your table.


You can also use the SYS_EXTRACT_UTC function to convert a date to GMT format in Oracle:

1
2
SELECT SYS_EXTRACT_UTC(your_date_column)
FROM your_table;


Again, replace your_date_column with the column in your table that contains the date you want to convert to GMT format, and replace your_table with the name of your table.