Re: Date from Number of Days
From: Jay B. Harlow [MVP - Outlook] (Jay_Harlow_MVP_at_msn.com)
Date: 02/01/05
- Next message: Jay B. Harlow [MVP - Outlook]: "Re: Strict on, Array of double, late binding"
- Previous message: Samuel R. Neff: "Re: Strict on, Array of double, late binding"
- In reply to: james: "Re: Date from Number of Days"
- Next in thread: james: "Re: Date from Number of Days"
- Reply: james: "Re: Date from Number of Days"
- Reply: james: "Re: Date from Number of Days"
- Reply: james: "Re: Date from Number of Days"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 1 Feb 2005 10:29:36 -0600
James,
My understanding of BCD is that each hex digit (nibble) is its decimal
digit.
http://www.webopedia.com/TERM/B/BCD.html
A byte that contains &H83 is bcd for 83 decimal.
A byte that contains &H01 is bcd for 1 decimal.
A byte that contains &H73 is bcd for 73 decimal.
What I'm not sure about is what if anything they do with the sign (I would
not expect a date to have a sign).
Now when you have a sequence of bytes, endian makes a difference (which end
of the sequence is most significant). My initial test was taking the first
byte as most significant (&H83), it may be that the last byte (&H73) is most
significant. In both cases the numbers seem way too large or way too small
for the conversion you gave earlier.
I'm curious on how Dataflex actually encodes their BCD.
Hope this helps
Jay
"james" <jjames700ReMoVeMe at earthlink dot net> wrote in message
news:uyXufICCFHA.3940@TK2MSFTNGP09.phx.gbl...
> Thanks for the ideas Jay. One quick question. As I mentioned in my
> previous post, the Dataflex developers all state that the database engine
> converts the date to number of days then to BCD before storing it in the
> database. Could that be the reason for the Hex values being so far off ?
> It seems to me that they are doing more .
> <pause in thinking>
>
> I just tried something, I took the Hex Values like:
> 830173 ( 83 01 73) and divided them by 365 and all of the values come out
> to: 2274.4465753424657534246575342466 ( 02/08/1999)
> OR
> 2274.526027397260273972602739726
> for Hex value: 83 02 02 ( 03/09/1999)
> OR
> 2280.0356164383561643835616438356
> for Hex value ( 83 22 13) (09/09/2004)
>
> I doubt if that is significant , but, it did seem kind of odd.
> I will continue to work with the suggestions you have provided Jay and
> will let you know what progress, if any, I make.
> Thanks again for all your help.
> james
>
>
> "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in message
> news:etoM49ACFHA.2380@tk2msftngp13.phx.gbl...
>> james,
>> I would start by using the routine to convert the date into the days #
>> (from the earlier post).
>>
>> Then I would compare those values to the ones you list.
>>
>> Unfortunately I don't see anything that is even close, in the bytes you
>> give.
>>
>> Which means that my routine may be "off"... (the Base Date or Base Days
>> constants).
>>
>> Looking at the numbers you give:
>>
>>> 02/10/1998 --82 98 10
>>> 04/21/1998 -- 82 98 80
>>
>> There are 70 days between these two dates, there is a difference of 70
>> between the 3rd byte, this would suggest the 3rd is the least significant
>> digit. I would then expect the first byte to be the most significant
>> digit (by examining the entire column).
>>
>>> 04/21/1998 -- 82 98 80
>>> 04/22/1999 --82 98 81
>>
>> Unfortunately these two are not a day apart, instead they are a year
>> apart!
>>
>>
>> Meaning:
>>> 01/08/1999 -- 83 01 73
>> days = 830173
>>> 03/09/1999 --83 02 02
>> days = 830202
>>> 02/10/1998 --82 98 10
>> days = 839110
>>> 04/21/1998 -- 82 98 80
>> days = 829880
>>> 03/19/1999 --83 02 12
>> days = 830212
>>> 04/22/1999 --82 98 81
>> days = 829881
>>> 11/19/1997 --82 97 27
>> days = 829727
>>
<<snip>>
- Next message: Jay B. Harlow [MVP - Outlook]: "Re: Strict on, Array of double, late binding"
- Previous message: Samuel R. Neff: "Re: Strict on, Array of double, late binding"
- In reply to: james: "Re: Date from Number of Days"
- Next in thread: james: "Re: Date from Number of Days"
- Reply: james: "Re: Date from Number of Days"
- Reply: james: "Re: Date from Number of Days"
- Reply: james: "Re: Date from Number of Days"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|