w3resource

Oracle FROM_TZ function

Convert a timestamp value to a timestamp with time zone in Oracle

The Oracle FROM_TZ() function is used to convert a TIMESTAMP value to a TIMESTAMP WITH TIME ZONE value by associating the timestamp with a specific time zone.

Uses of Oracle FROM_TZ() Function:
  • Converting a timestamp to a time zone-based value: Convert a TIMESTAMP value into a TIMESTAMP WITH TIME ZONE using a specified time zone.

  • Handling time zone conversions in global applications: Adjust timestamps to reflect different time zones, ensuring consistency across geographic locations.

  • Facilitating timezone-aware date and time comparisons: Compare timestamps accurately across different time zones.

  • Preserving date and time accuracy in distributed systems: Maintain timestamp precision across systems operating in various time zones.

  • Supporting timezone-aware queries for reporting: Enable time zone-specific queries and reporting in global databases.

Syntax:

FROM_TZ (timestamp_value, time_zone_value)

Parameters

Name Description
timestamp_value The value to convert to a TIMESTAMP with TIME ZONE value.
time_zone_value Convert timestamp_value to a TIMESTAMP with TIME ZONE value.

Applies to:
Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i

Pictorial Presentation

Pictorial Presentation of Oracle EXTRACT function

Example: Oracle FROM_TZ () function

The following statement returns a timestamp value to TIMESTAMP with TIME ZONE :

SQL> SELECT FROM_TZ(TIMESTAMP '2015-04-28 09:00:00', '4:00')
  2  FROM DUAL;

Sample Output:

FROM_TZ(TIMESTAMP'2015-04-2809:00:00','4:00')
---------------------------------------------------------------------------
28-APR-15 09.00.00.000000000 AM +04:00

Previous: EXTRACT(datetime)
Next: LAST_DAY



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/oracle/datetime-functions/oracle-from_tz-function.php