Re: Date from Number of Days
From: james (jjames700ReMoVeMe)
Date: 01/30/05
- Next message: james: "Re: Date from Number of Days"
- Previous message: Herfried K. Wagner [MVP]: "Re: listview scrollbars"
- In reply to: Jay B. Harlow [MVP - Outlook]: "Re: Date from Number of Days"
- Next in thread: Cor Ligthert: "Re: Date from Number of Days"
- Reply: Cor Ligthert: "Re: Date from Number of Days"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 30 Jan 2005 12:29:12 -0600
Jay, great solution! Both functions work very well. After my brain kicked in and figured out how to use them correctly :-)
I really do appreciate your help. The problem I had encountered was that the Dataflex database system
used 00/00/0000 as the Base Date. And that the database engine stored that number in Hex in the original
(DOS based) file system. I could find and extract the numbers, but, I could not find out exactly how the data was being
converted to a meaningful date. I am learning to have a lot more respect for people that write database converters now!
james
"Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in message news:OaAny1pBFHA.2428@TK2MSFTNGP14.phx.gbl...
> James,
> Use DateTime.AddDays to find a date given the number of days since a "well known" date. Or to go the other direction use
> DateTime.Subtract to find the number of days since a "well known" date.
>
> The "problem" you are going to have is that Datetime.MinDate is 01/01/0001 as opposed to 00/00/0000, I would simply add or
> subtract the difference in days as needed...
>
> You may want to consider a pair of functions, something like:
>
> Private Const BaseDate As DateTime = #1/1/1900#
> Private Const BaseDays As Integer = 36525
>
> Public Function ToFileDateTime(ByVal value As DateTime) As Integer
> Dim ts As TimeSpan = value.Date.Subtract(BaseDate)
> Return CInt(ts.TotalDays) + BaseDays
> End Function
>
> Public Function FromFileDateTime(ByVal days As Integer) As DateTime
> Return BaseDate.AddDays(days - BaseDays)
> End Function
>
> Where BaseDate & BaseDays are your "well known" date.
>
> Of course if you need dates pre 01/01/0001 then you may have a problem...
>
> Hope this helps
> Jay
>
> "james" <jjames700ReMoVeMe at earthlink dot net> wrote in message news:edEivQoBFHA.3616@TK2MSFTNGP11.phx.gbl...
>>I have a problem that at first glance seems not that hard to figure out. But, so far, the answer has escaped me. I have an old
>>database file that has the date(s) stored in it as number of days.
>> An example is: 36,525 represents 01/01/1900. The starting point date is considered to be :
>> 00/00/0000. I have looked thru Help and used Google and have not really found an answer.
>> I know that Leap Years need to be accounted for too.
>> Any suggestions on where to start ?
>> james
>>
>>
>
>
- Next message: james: "Re: Date from Number of Days"
- Previous message: Herfried K. Wagner [MVP]: "Re: listview scrollbars"
- In reply to: Jay B. Harlow [MVP - Outlook]: "Re: Date from Number of Days"
- Next in thread: Cor Ligthert: "Re: Date from Number of Days"
- Reply: Cor Ligthert: "Re: Date from Number of Days"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|