Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
FoxPro Date Processing
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
brendan.mcken...@gmail.com  
View profile  
 More options May 19 2006, 4:24 pm
Newsgroups: microsoft.public.dotnet.framework
Followup-To: microsoft.public.dotnet.framework
From: brendan.mcken...@gmail.com
Date: 18 May 2006 23:24:59 -0700
Local: Fri, May 19 2006 4:24 pm
Subject: FoxPro Date Processing
Hello,

I am writing a class to process FoxPro .dbf files, all has been going
well, but I have recently hit a snag.  I'm trying to convert FoxPro's
DateTime field (T) to a System.DateTime.  FoxPro's field is 2 32bit
integers: one stores the date, the other stores the time, stored in
reverse byte order. (2f 4a 12 9a== 9a 12 4a 2f)

Easy... here's the hard part.  The date integer stores the number of
days from 1/1/4712BC (yes... BC).  The time integer stores the number
of milliseconds from 00:00:00.

Processing the time was easy ( DateTime.AddMilliseconds() ).
Processing the date, is not.

Is there anyone who can lend a hand and help me process this date?

The date integer: 2453809 should become 20/04/2006

My current process is:

DateTime dt = new DateTime(1, 1, 1);
dt = dt.AddDays(days);
dt = dt.AddYears(-4713);

This results in a DateTime which is 2 days off, and I'm afraid it may
result in more problems due to leap years with other dates.

Can anyone help me out with this?

Thanks!

Brendan


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kalpesh  
View profile  
 More options May 19 2006, 6:05 pm
Newsgroups: microsoft.public.dotnet.framework
From: "Kalpesh" <shahkalp...@gmail.com>
Date: 19 May 2006 01:05:56 -0700
Local: Fri, May 19 2006 6:05 pm
Subject: Re: FoxPro Date Processing
BTW, how are you reading the dbf files?
I suppose, it will be better to read dbf files using oledb provider
which supports reading foxpro files

HTH
Kalpesh


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brendan McKenzie  
View profile  
 More options May 19 2006, 6:18 pm
Newsgroups: microsoft.public.dotnet.framework
From: "Brendan McKenzie" <brendan.mcken...@gmail.com>
Date: 19 May 2006 01:18:53 -0700
Local: Fri, May 19 2006 6:18 pm
Subject: Re: FoxPro Date Processing
If only it were that simple... the tables in the database rely on some
.prg files that were compiled into the foxpro application, meaning I
can't access the data unless I'm accessing it through the application
that was written.  Considering this is a 3rd party addon for the
application, I don't have such luxuries.

I'm reading the dbf files using a FileStream and BinaryReader combo.
Using the following website as my reference:

http://www.clicketyclick.dk/databases/xbase/format/dbf.html


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brendan McKenzie  
View profile  
 More options May 19 2006, 7:10 pm
Newsgroups: microsoft.public.dotnet.framework
From: "Brendan McKenzie" <brendan.mcken...@gmail.com>
Date: 19 May 2006 02:10:13 -0700
Local: Fri, May 19 2006 7:10 pm
Subject: Re: FoxPro Date Processing
The Solution:

[code]
                byte[] ArrDate = new byte[] { Data[Offset], Data[Offset + 1],
Data[Offset + 2], Data[Offset + 3] };
                byte[] ArrTime = new byte[] { Data[Offset + 4], Data[Offset + 5],
Data[Offset + 6], Data[Offset + 7] };
                int LngDate = BitConverter.ToInt32(ArrDate, 0);
                int LngTime = BitConverter.ToInt32(ArrTime, 0);

                if ((LngDate * LngTime) != 0)
                {
                        LngDate -= 1721426;
                        DateTime dt = new DateTime(1, 1, 1, 0, 0, 0);

                        dt = dt.AddMilliseconds(LngTime);
                        dt = dt.AddDays(LngDate);

                        return dt;
                }
                else
                {
                        return null;
                }
[!code]

Quote: "work out what FoxPro's date is at 1/1/0001, then try working
relative to that"


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google