Kbase P175837: What is DATETIME
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  5/13/2011 |
|
Status: Verified
GOAL:
What is DATETIME
GOAL:
How to use DATETIME data type
GOAL:
How to use DATETIME function
FACT(s) (Environment):
All Supported Operating Systems
OpenEdge 10.x
FIX:
The DATETIME data type consists of two parts, one an ABL date and one an ABL time. The unit of time is milliseconds from midnight.
The DATETIME data type is useful for dealing with the local time of the session that assigned the data, not absolute time. It is also useful for applications that deal with datetime data from one timezone.
The DATETIME function creates a date and time from database field, a variable, or a character string.
A code sample using the DATETIME data type and DATETIME function:
DEF VAR my-datetime as DATETIME.
my-datetime = DATETIME(TODAY, MTIME).
MESSAGE my-datetime
VIEW-AS ALERT-BOX INFO BUTTONS OK.
/* The statement above is equivalent to "my-datetime = NOW". */
You can add or subtract DATETIME values to calculate intervals. ABL allows to provide functions to work with DATETIME. ADD-INTERVAL and INTERVAL are two examples of DATETIME functions:
An example of the INTERVAL function:
DEFINE VARIABLE startTime AS DATETIME INIT "01-01-2002 07:00:00" NO-UNDO.
DEFINE VARIABLE endTime AS DATETIME INIT "01-01-2002 07:15:00" NO-UNDO.
DEFINE VARIABLE i AS INT64 NO-UNDO.
DISP startTime endTime.
i = INTERVAL(startTime, endTime, "milliseconds").
MESSAGE i VIEW-AS ALERT-BOX INFO BUTTONS OK.
An example of the ADD-INTERVAL function:
DEFINE VARIABLE startTime AS DATETIME INIT "01-01-2002 07:15:00" NO-UNDO.
DEFINE VARIABLE newTime AS DATETIME 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.