Kbase P176743: What is DATETIME-TZ
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  13/05/2011 |
|
Status: Verified
GOAL:
What is DATETIME-TZ
GOAL:
How to use DATETIME-TZ data type
GOAL:
How to use DATETIME-TZ function
FACT(s) (Environment):
All Supported Operating Systems
OpenEdge 10.x
FIX:
The DATETIME-TZ data type consists of three parts: an ABL date and time (as for DATETIME), and an integer representing the time zone offset from Coordinated Universal Time (UTC) in minutes. ABL stores DATETIME-TZ data in UTC, along with the time zone offset of the DATETIME-TZ. This allows for indexing of datetime data based on absolute times. UTC is the current universal standard for time. Local time zone values are relative to UTC (for example, Eastern Standard Time is UTC?05:00). For example, if a DATETIME-TZ field is created in Bedford, MA (time zone offset UTC-05:00) on June 20, 2003 at 15:55, the value stored in the database is 6/20/03 at 20:55 (time converted to milliseconds) with a -5 hour (-300 minute) offset.
Many applications deal with data that spans time zones. The DATETIME-TZ data type is useful for dealing with datetime data in absolute time. Here are some examples of when you might use the DATETIME-TZ data type:
? An order entry application that accepts orders from around the world wants the order datetimes stored in UTC so that they index in absolute time.
? An ABL application communicating with a Web service that includes an XML Schema datetime in its interface can use DATETIME-TZ parameters to communicate in absolute time, and to preserve time zone information from the datetime data coming from the Webservice.
? An ABL client/AppServer communication should also use DATETIME-TZ, since the client and the AppServer might be in different time zones. For DATETIME-TZ, the value represents an absolute date and time, and there is no data loss when passing parameters between sessions in different time zones.
DEF VAR my-datetime-tz as DATETIME-TZ.
my-datetime-tz = DATETIME-TZ(TODAY, MTIME, TIMEZONE).
MESSAGE my-datetime-tz
VIEW-AS ALERT-BOX INFO BUTTONS OK.
/* The statement above is equivalent to "my-datetime-tz = NOW". */
In addition to performing operations like adding a time interval to, or subtract a time interval from DATE, TIME, or DATETIME-TZ value in units (e.g. years, months, days, weeks, etc) ABL provides functions that work with DATETIME-TZ values. ADD-INTERVAL and INTERVAL are two examples of functions:
Using INTERVAL:
DEFINE VARIABLE startTime AS DATETIME-TZ INIT "01-01-2002 07:00:00" NO-UNDO.
DEFINE VARIABLE endTime AS DATETIME-TZ INIT "01-01-2002 07:15:00" NO-UNDO.
DEFINE VARIABLE i AS INT64 NO-UNDO.
DISP startTime endTime WITH SIDE-LABEL.
i = INTERVAL( endTime, startTime,"milliseconds").
N>MESSAGE i VIEW-AS ALERT-BOX INFO BUTTONS OK.
Using ADD-INTERVAL:
DEFINE VARIABLE startTime AS DATETIME-TZ INIT "01-01-2002 07:15:00" NO-UNDO.
DEFINE VARIABLE newTime AS DATETIME-TZ NO-UNDO.
MESSAGE "This is a StartTime: " startTime
VIEW-AS ALERT-BOX INFO BUTTONS OK.
newTime = ADD-INTERVAL(startTime, 15, "minutes").
MESSAGE "This is a NewTime + 15 Minutes: " newtime
VIEW-AS ALERT-BOX INFO BUTTONS OK..