Feedback
Did this article resolve your question/issue?

   

Article

What is DATETIME

Information

 
TitleWhat is DATETIME
URL NameP175837
Article Number000161282
EnvironmentProduct: OpenEdge
Version: 10.x, 11.x, 12.x
OS: All Supported Operating Systems
Other: N/A
Question/Problem Description
What is DATETIME
How to use DATETIME data type
How to use DATETIME function
Steps to Reproduce
Clarifying Information
Error Message
Defect/Enhancement Number
Cause
Resolution

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.

Workaround
Notes
Last Modified Date11/20/2020 6:56 AM
Attachment 
Files
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.