Problem Note 51549: The B8601DT, E8601DT, E8601DZ, and TOD formats write midnight as 24:00:00 rather than 00:00:00
The documentation for the B8601DTw.d and E8601DTw.d formats states that the maximum value for the hour portion of the time is 23. Under certain conditions, these formats write the time portion as 24:00:00, which is incorrect. If a value of midnight is output, the correct datetime value is 00:00:00 for the following day. The same is true for the TODw.d and E8601DZw.d formats.
The sample code on the Full Code illustrates the problem. The output that is generated by the code can be viewed on the Results tab.
There is currently no circumvention for this problem.
Operating System and Release Information
SAS System | Base SAS | z/OS | 9.2 TS1M0 | 9.4 TS1M2 |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS1M0 | |
Microsoft Windows XP 64-bit Edition | 9.2 TS1M0 | |
Microsoft® Windows® for x64 | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Standard Edition | 9.2 TS1M0 | |
Microsoft Windows XP Professional | 9.2 TS1M0 | |
Windows Vista | 9.2 TS1M0 | |
Windows Vista for x64 | 9.2 TS1M0 | |
64-bit Enabled AIX | 9.2 TS1M0 | 9.4 TS1M2 |
64-bit Enabled HP-UX | 9.2 TS1M0 | 9.4 TS1M2 |
64-bit Enabled Solaris | 9.2 TS1M0 | 9.4 TS1M2 |
HP-UX IPF | 9.2 TS1M0 | 9.4 TS1M2 |
Linux | 9.2 TS1M0 | 9.4 TS1M2 |
Linux for x64 | 9.2 TS1M0 | 9.4 TS1M2 |
OpenVMS on HP Integrity | 9.2 TS1M0 | 9.4 TS1M2 |
Solaris for x64 | 9.2 TS1M0 | 9.4 TS1M2 |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
The B8601DTw.d and E8601DTw.d formats write values very close to midnight as 24:00:00. The correct value is 00:00:00 of the following day. This occurs when a value is summed with a datetime and the result is very close but not exactly midnight. The third computed value below is unable to be represented precisely in floating-point representation, and although it is very close to midnight, it is not exactly. The hexadecimal output shows the imprecision of the value. The formats incorrectly write the value as a time value of 24:00:00 instead of the correct value of 00:00:00 of the following day.
The TIMEPART function creates the TM variable that is the time portion of the datetime value. The TODw.d format writes the time as 24:00 instead of 00:00 as expected.
data _null_;
do dt = 1680911999.998 to 1680912000.002 by 0.001;
tm=timepart(dt);
put dt=hex16. dt=14.3 dt=b8601DT26.3 dt=datetime20. dt=e8601DT26.3 tm=tod6.;
end;
run;
596 data _null_ ;
597 do dt = 1680911999.998 to 1680912000.002 by 0.001 ;
598 tm=timepart(dt);
599 put dt=hex16. dt=14.3 dt=b8601DT26.3 dt=datetime20. dt=e8601DT26.3 tm=tod6.;
600 end ;
601 run ;
dt=41D90C2B9FFFDF3B dt=1680911999.998 dt=20130406T235959998 dt=07APR2013:00:00:00
dt=2013-04-06T23:59:59.998 tm=24:00
dt=41D90C2B9FFFEF9D dt=1680911999.999 dt=20130406T235959999 dt=07APR2013:00:00:00
dt=2013-04-06T23:59:59.999 tm=24:00
dt=41D90C2B9FFFFFFF dt=1680912000.000 dt=20130407T240000000 dt=07APR2013:00:00:00
dt=2013-04-07T24:00:00.000 tm=24:00
dt=41D90C2BA0001061 dt=1680912000.001 dt=20130407T000000001 dt=07APR2013:00:00:00
dt=2013-04-07T00:00:00.001 tm=00:00
dt=41D90C2BA00020C3 dt=1680912000.002 dt=20130407T000000002 dt=07APR2013:00:00:00
dt=2013-04-07T00:00:00.002 tm=00:00
Type: | Problem Note |
Priority: | medium |
Topic: | SAS Reference ==> Formats ==> Date and Time
|
Date Modified: | 2013-11-08 09:47:28 |
Date Created: | 2013-11-07 12:04:33 |