in

Convert Date to Local Time Zone in Oracle


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:

Written by Rony Dsouza

Rony is an Oracle programmer, having more than 15 years of experience. He likes to write on SQL, PL/SQL, and Oracle Apex topics. Also, expertise in Python, PHP, MySQL, JavaScript, etc.

Leave a Reply

Your email address will not be published. Required fields are marked *