Encoding/binary 3 bytes date

Dear all,

I’m converting a binary file and I do not fin how to convert a 3 bytes date. it seems to be int16, because int32 and int64 trigger " index out of range".

But I do not find how to find my date.

These data in hexa 750C1B should be the day before yesterday (27th)

Thanks a lot


Only the number 27 or the complete date 2017-12-27? Do you expect a time to be encoded, too, or only the date?

That’s just the date parts, one byte each (year minus 1900).


1 Like

You got it !
Thank you very much @calmh
Have a good day.

Hello again,

my last conversion is to pass bytes in float

C4 A7 4F FF should be around 3,72

C0 2A 10 should become 2.10
I have an out of range with 3 bytes (normal :wink: )

Thanks a lot

Check the specs for the format you are decoding. The first example was clear enough to understand by eye, float formats are typically not.

I’have only this information that it’s a Binary-coded decimal on 3 or 4 bytes :frowning:
Maybe it’s not enough.

It’s not just BCD at least.

We can see that in BCD:

C0 2A10

But what is C and A? C is typically a positive sign in BCD. A is a decimal point maybe? If so then this is indeed “+02.10” but that’s mostly a guess to fit the data.

The same system as above would make this 4.74 plus a few F nibbles that mean “something”, maybe just padding, not 3.72 as you expect. Or maybe your expectation is wrong, but decoding something with an unknown format and incorrect data on what it’s supposed to mean is tricky. :slight_smile:

And now I’m curious. What is the source of the file - an old mainframe somewhere?

The two examples are also curiously different. One uses padding (if that is what it is) while the other has a leading zero. Why add an extra byte of padding when the first example doesn’t? Odd.

There are all kinds of variants and dialects of this: https://en.wikipedia.org/wiki/Binary-coded_decimal. Go experiment! :wink:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.