Siemens DATE_AND_TIME Decoder
Decode and encode the classic Siemens S7 DATE_AND_TIME 8-byte BCD format. Inspect year, month, day, hour, minute, second, millisecond and weekday fields and validate the encoded calendar date.
BCD(Byte 6) × 10 + high nibble of Byte 7.
—
—
What Is Siemens S7 DATE_AND_TIME?
DATE_AND_TIME is a classic Siemens S7 date and time representation occupying eight bytes. Its calendar and clock fields are stored primarily using packed BCD, or Binary Coded Decimal.
The format carries year, month, day, hour, minute, second, milliseconds and a weekday value.
Siemens DATE_AND_TIME 8-Byte Format
Byte 0 Year
Byte 1 Month
Byte 2 Day
Byte 3 Hour
Byte 4 Minute
Byte 5 Second
Byte 6 Millisecond hundreds/tens
Byte 7 Millisecond units + WeekdayBytes 0 through 6 use packed BCD. The final byte combines two different fields: the high nibble stores the last millisecond digit and the low nibble stores the day of the week.
What Is Packed BCD?
Packed Binary Coded Decimal stores two decimal digits in one hexadecimal byte. Each nibble must therefore contain a value from 0 through 9.
Hex byte:
47
High nibble:
4
Low nibble:
7
BCD value:
47 decimal
A value such as 4A is not valid packed BCD because hexadecimal A
cannot represent a decimal BCD digit.
DATE_AND_TIME Year Mapping
Only two decimal year digits are physically stored. Siemens’ classic DATE_AND_TIME range maps them across the years 1990 through 2089.
Stored 90–99
→ 1990–1999
Stored 00–89
→ 2000–2089
For example, BCD byte 24 represents the year 2024, while
95 represents 1995.
Month, Day and Time Fields
| Field | Valid Decoded Range |
|---|---|
| Month | 1–12 |
| Day | Valid calendar day for selected month/year |
| Hour | 0–23 |
| Minute | 0–59 |
| Second | 0–59 |
| Milliseconds | 0–999 |
| Weekday | 1–7 |
How Milliseconds Are Stored
Milliseconds span byte 6 and the upper nibble of byte 7.
Example:
Byte 6 = 12
Byte 7 high nibble = 3
BCD(Byte 6) = 12
Milliseconds =
12 × 10 + 3
= 123 msThe lower nibble of byte 7 is not part of milliseconds; it contains the weekday.
Siemens DATE_AND_TIME Weekday
| Value | Weekday |
|---|---|
| 1 | Sunday |
| 2 | Monday |
| 3 | Tuesday |
| 4 | Wednesday |
| 5 | Thursday |
| 6 | Friday |
| 7 | Saturday |
The calculator also independently computes the weekday from the decoded calendar date and reports whether the stored weekday agrees with it.
DATE_AND_TIME Decode Example
24 09 02 14 35 47 12 32
24
Year = 2024
09
Month = 9
02
Day = 2
14
Hour = 14
35
Minute = 35
47
Second = 47
12
First two millisecond digits
3
Millisecond units
2
Weekday = Monday
Result:
2024-09-02 14:35:47.123BCD Validation
The decoder validates each BCD field before attempting to interpret it. Both the high and low nibbles of the full BCD bytes must be decimal digits from 0 to 9.
Valid BCD:
59
Invalid BCD:
5A
AF
FFCalendar Validation
BCD-valid bytes do not automatically describe a valid date. For example, February 31 can be represented with valid BCD digits but is not a real calendar date.
The tool therefore separately validates the decoded year, month and day, including leap-year rules.
Leap Year Example
2024-02-29
Valid
2023-02-29
InvalidThe encoder refuses invalid calendar combinations rather than generating an 8-byte value that contains an impossible date.
DATE_AND_TIME vs Newer Siemens Date Types
The tool specifically handles the classic eight-byte S7 DATE_AND_TIME format. Newer Siemens environments can also provide types such as DATE, TIME, TIME_OF_DAY, LDT and DTL that use different binary layouts.
Those types should not be decoded as an eight-byte DATE_AND_TIME value simply because they also represent calendar or clock information.
Siemens DATE_AND_TIME Decoder FAQs
How many bytes does S7 DATE_AND_TIME use?
Is DATE_AND_TIME stored as Unix time?
What year range can DATE_AND_TIME represent?
How does year byte 99 decode?
How does year byte 00 decode?
Where are milliseconds stored?
Where is the weekday stored?
What does weekday 1 mean?
Does the tool check impossible dates?
Can I encode a DATE_AND_TIME value?
Decode Siemens S7 DATE_AND_TIME Values
Convert classic Siemens eight-byte BCD date/time values into readable calendar timestamps or generate valid DATE_AND_TIME bytes from year, month, day, clock, milliseconds and weekday values.