The format of the internal 8-byte date-time stamps in new ADS BIFs

Document ID : KB000028740
Last Modified Date : 14/02/2018
Show Technical Document Details

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 you cannot perform natural arithmetic on these fields and expect to get a meaningful result. If you perform such arithmetic, and then treat resulting 8-byte fields as an internal date-time stamp, then either a DC175036 abend will occur or the result will be incorrect, depending on the values involved.

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 the manual "CA IDMS SQL Reference Guide", Chapter 3 "Data Types and Null Values", sub-section "Representation of Date/Time Values", or use this link.