Working With Timezones White Paper
Working With Timezones White Paper
Working With Timezones White Paper
Introduction 1
DB Time Zone 4
Date and time fields are implemented using the following date time data types:
» DATE
» TIMESTAMP
» TIMESTAMP WITH TIME ZONE
» TIMESTAMP WITH LOCAL TIME ZONE
These data types enable consistent information to be stored about the time of events and transactions,
while also supporting the requirement to display values in different time zones.
» Time Zones in Oracle BI Publisher Reports: Simple instructions to implement the different
reporting scenarios in Oracle BI Publisher reports without the need to understand the time zone
settings and how they impact the values reported.
» Time Zone Settings: An overview of the time zone settings that impact the value of date time fields
in different reporting scenarios.
» Time Zones Treatment in Oracle BI Publisher Reports: Different reporting scenarios that highlight
the impact of time zone settings.
<?format-date:TRANSACTION_DATE;’XDODEFDATE’?>
<?format-date:TRANSACTION_DATE;’XDODEFDATE XDODEFTIME’?>
For more information on XDODEFDATE and XDODEFTIME, see Implementing Localization Formatting in Oracle BI
Publisher Reports in the Oracle Fusion Applications Developer’s Guide.
1. Convert the date to a string in the data model using one of the following commands:
TO_CHAR(<DATETIME>,‘YYYY-MM-DD’)
TO_CHAR(<DATETIME>,‘YYYY-MM-DD’”T”‘HH24:MI:SS’)
2. In your RTF layout template, use XDODEFDATE or XDODEFTIME to format the date:
<?format-date:TRANSACTION_DATE;’XDODEFDATE’?>
<?format-date:TRANSACTION_DATE;’XDODEFDATE XDODEFTIME’?>
To prevent the above date from being converted to the user preferred time zone, use the TO_CHAR function. For
example:
SELECT TO_CHAR(
,’YYYY-MM-DD’) creation_date
FROM ap_invoices_all
SELECT TO_CHAR(
,’YYYY-MM-DD’) creation_date
FROM ap_invoices_all
Note: You do not need to wrap the FROM_TZ with TO_CHAR if you are using the WHERE clause of the data
model’s SQL statement.
For a list of the available time zones, run the following SQL statement:
SELECT *
FROM V$TIMEZONE_NAMES
DB Time Zone
DB time zone is the setting at the database level and the actual time zone in which the date and time fields are
stored by default. For example, the user interface may display the following date field in Pacific Standard Time
(UTC-08:00):
In a database with a DB time zone of UTC, the actual date and time stored in the date field is:
To convert the date field to the canonical format when a time element or time zone is not included, JDBC adds a
time of midnight (00:00:00) to the time zone of the JVM.
FROM dual
The generated XML converts the date field to the following canonical format:
<TRANSACTION_DATE>2014-01-01T00:00:00.000-07:00</TRANSACTION_DATE>
For reports to display the dates and times in the format defined in the Oracle Fusion Applications preferences, use
the format masks XDODEFDATE and XDODEFTIME. In the report layout, you format the field using the following
command:
<?format-date:TRANSACTION_DATE;’XDODEFDATE’?>
The above date would also be displayed in the user preferred time zone.
Consider the following command in the XML generated by the data model:
<TRANSACTION_DATE>2014-01-01T00:00:00.000-07:00</TRANSACTION_DATE>
A user whose preferred time zone is set to Honolulu UTC-10:00 would see the following value reported, although the
format would depend upon the Oracle Fusion Applications preferences:
The date value has been shifted back to the previous day because:
» The JVM appends midnight (00:00:00) and the time zone UTC-07:00 to the value in the XML to convert the date
to the canonical format.
» The date is shifted back an additional three hours into the previous day because the layout displays the dates in
the user preferred time zone of UTC-10:00.
» Three hours is the difference between the user preferred time zone of UTC-10:00 and the time zone
appended to the date in the XML of UTC-07:00.
<?format-date:TRANSACTION_DATE;’XDODEFDATE’?>
<?format-date:TRANSACTION_DATE;’XDODEFDATE XDODEFTIME’?>
For more details on the user preferences setting, see Setting Preferences in the Oracle Fusion Middleware User’s
Guide for Oracle Business Intelligence Enterprise Edition.
Since the JVM will convert date fields in the XML to canonical format, you must convert the date time field to a string
in the data model using the function TO_CHAR. For example:
TO_CHAR(TRANSACTION_DATE,YYYY-MM-DD’)
Note: Using the TRUNC function on a date time field in the SELECT clause will not prevent the JVM from converting
the date time field to the canonical format. Although TRUNC(<DATETIME>) resets the time to 00:00:00, the field is
still a DATE data type. Therefore, you should use the TO_CHAR function instead.
TO_CHAR(<DATETIME>,‘YYYY-MM-DD’)
TO_CHAR(<DATETIME>,‘YYYY-MM-DD’”T”‘HH24:MI:SS’)
For this date conversion, you can use the function FROM_TZ in the following command:
This command converts the field TRANSACTION_DATE from the DB time zone to the time zone
'America/Los_Angeles'.
If a transaction has a CREATION_DATE of 02 January 2014 00:01 in the database which is using the UTC time
zone, then the above command would return the date below in UTC-08:00:
To display the date in your report, use the following statement in the data model:
SELECT TO_CHAR(
,’YYYY-MM-DD’) creation_date
FROM ap_invoices_all
This will result in the following value in the XML which can be formatted using XDODEFDATE in the report layout,
ensuring that no further time zone conversion will take place:
<CREATION_DATE>2014-01-01</CREATION_DATE>
Using TRUNC in the SELECT clause will not prevent a date time field from being converted into the canonical
format by the JVM when creating the XML. However, you can still use TRUNC in the WHERE clause. For example:
SELECT TO_CHAR(
,’YYYY-MM-DD’) creation_date
FROM ap_invoices_all
= TO_DATE('01-JAN-2014','DD-MON-YYYY')
CONNECT WITH US
blogs.oracle.com/oracle Copyright © 2014, Oracle and/or its affiliates. All rights reserved. This document is provided for information purposes only, and the
contents hereof are subject to change without notice. This document is not warranted to be error-free, nor subject to any other
facebook.com/oracle warranties or conditions, whether expressed orally or implied in law, including implied warranties and conditions of merchantability or
fitness for a particular purpose. We specifically disclaim any liability with respect to this document, and no contractual obligations are
formed either directly or indirectly by this document. This document may not be reproduced or transmitted in any form or by any
twitter.com/oracle means, electronic or mechanical, for any purpose, without our prior written permission.
oracle.com Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and
are trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are
trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group. 0714