The format of the internal 8-byte date-time stamps in r17.0 ADS BIFs
search cancel

The format of the internal 8-byte date-time stamps in r17.0 ADS BIFs

book

Article ID: 28740

calendar_today

Updated On:

Products

IDMS IDMS - Database IDMS - ADS

Issue/Introduction

A number of new ADS BIFs were added in r17.0 to convert various date and time values between internal and external formats. 

These new BIFs are DATEEXT, DATEINT, DISPDT, DATETIMX, DTINT, TIMEEXT, TIMEINT.

The 8-byte internal date-time stamps should be defined in the ADS dialog as a PIC 9(18) USAGE COMP field.

The 64 bits in one of these fields represent a date-time stamp as follows:-

Bits  0 - 26   Number of Days since January 1, 0001
Bits 27 - 43   Number of seconds in this day since midnight
Bits 44 - 63   Number of microseconds since the last second

Note that this means that the entire 8-byte numeric field is not an absolute number of microseconds and therefore it is not possible to perform natural arithmetic on these fields and expect to get a meaningful result. If such arithmetic is performed, and the resulting 8-byte field is treated as an internal date-time stamp, then either a DC175036 abend will occur or the result will be incorrect, depending on the values involved.

Environment

Release: All supported releases.
Component: ADS.

Resolution

Sample ADS code to convert an 8-byte date-time stamp (WS-INTERNAL-DTS) to numbers of days (WS-DAYS), seconds WS-SECS, and microseconds (WS-MS), and then the total number of microseconds (WS-MICROSECONDS) is as follows:-

DIVIDE 1048576 INTO WS-INTERNAL-DTS GIVING WS-MICROSECONDS
                                  REMAINDER WS-MS.
DIVIDE  131072 INTO WS-MICROSECONDS GIVING WS-DAYS
                                  REMAINDER WS-SECS.
COMPUTE WS-MICROSECONDS = ( ( ( WS-DAYS * 86400 ) + WS-SECS )
                                  * 1000000 ) + WS-MS. 

For more information about the internal representation of date-time fields, see Representation of Date/Time Values.