Convert Time of Day (TOD) Clock values from the STCK and STCKE
instructions to date/time and UNIX date/time values.
Convert From STCK
Notes About TOD Clock Values
Excel Formulas for TOD Clock Values
Use these formulas to convert a STCK TOD clock value (not STCKE) to a date and time in Excel. Formula assume TOD clock value is in cell B1:
(Thanks to Simon Foley)
- Date: =(((HEX2DEC(LEFT(B1,8))*4294967296)+(HEX2DEC(RIGHT(B1,8))))/4096000000/86400)+2
- Time: =(((HEX2DEC(LEFT(B1,8))*4294967296)+(HEX2DEC(RIGHT(B1,8))))/4096000000/86400)
z/Series mainframes store the Time of Day (TOD) Clock as a 104
bit register holding a value that represents the time elapsed
since 00:00:00 on Jan 1, 1900. Bit 51 of this register is incremented
You can get this information using one of two instructions:
1. STCK (Store Clock) - this is the older style instruction.
You get a doubleword which is the first 64 bits of the TOD clock
2. STCKE (STCK Extended) - You get four words that look like::
So you get the whole TOD clock, an extra byte of zeroes at the
beginning, and a programmable section used by z/OS at the end.
The problem with a 104 bit TOD clock is that it will run out
of bits at the end of 17-Sep-2042, and the time will reset to 01-Jan-1900.
To solve this, later Mainframe models will use a larger TOD clock
register and the high order byte from the STCKE instruction will
To get a correct UTC value, you need to add 'leap seconds' to
the TOD clock value. This number of leap seconds for the current
time is stored in the CVT field CVTLSO.
Of course this assumes that the TOD Clock is set to UTC time,
and an offset to local time is specified in the CLOCKxx parmlib
An interesting fact: STCK will ALWAYS produce a unique number
throughout a CPC. The STCKE instruction will ALWAYS produce a
unique number throughout a sysplex.