Convert Date to Local Time Zone in Oracle

Convert Date to Local Time Zone in Oracle

  • SQL
  • 1 min read


In Oracle, you can use the cast function to convert the date to the local time zone. Below are the examples:

Date to Local Time Zone Example

The following SQL query converts the date to local time zone format using the cast function:

SELECT CAST('21-OCT-2022'
AS TIMESTAMP WITH LOCAL TIME ZONE)
FROM DUAL;

Output

21-OCT-22 12.00.00.000000 AM

Another example of converting to the local time zone using the cast function:

select cast(date'2022-10-21' as timestamp) at time zone 'UTC' dt
from dual;

Output:

21-OCT-22 12.00.00.000000 AM UTC

Converting date with a particular date format:

SELECT CAST(TO_DATE('21-Oct-2022', 'DD-Mon-YYYY')
AS TIMESTAMP WITH LOCAL TIME ZONE)
FROM DUAL;

Output:

21-OCT-22 12.00.00.000000 AM

See also: