Message from discussion
FoxPro Date Processing
Path: g2news2.google.com!postnews.google.com!j55g2000cwa.googlegroups.com!not-for-mail
From: "Brendan McKenzie" <brendan.mcken...@gmail.com>
Newsgroups: microsoft.public.dotnet.framework
Subject: Re: FoxPro Date Processing
Date: 19 May 2006 02:10:13 -0700
Organization: http://groups.google.com
Lines: 29
Message-ID: <1148029812.994306.273540@j55g2000cwa.googlegroups.com>
References: <1148019899.674915.149110@j55g2000cwa.googlegroups.com>
<1148025956.469440.197020@i40g2000cwc.googlegroups.com>
<1148026733.599782.149000@38g2000cwa.googlegroups.com>
NNTP-Posting-Host: 203.206.205.212
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1148029818 17244 127.0.0.1 (19 May 2006 09:10:18 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 19 May 2006 09:10:18 +0000 (UTC)
In-Reply-To: <1148026733.599782.149000@38g2000cwa.googlegroups.com>
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: j55g2000cwa.googlegroups.com; posting-host=203.206.205.212;
posting-account=hzNbVw0AAAAGsqmhUGkX4L1CU-cjv8PI
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"