|
-
Dec 18th, 2002, 12:28 AM
#1
Thread Starter
Junior Member
Date Problems
I use this command:
DateAdd("d", DateDiff("d", Now, DateAdd("d", somevariable, DateSerial(1900, 1, 1))), Date)
Where "somevariable" is the amount of days after 1900 (given to me by C++). Although using this method for the current amount of days since 1900 (that C++ gives me) I'll end up with a day like 11/22/2002. Any body have any fixes?
-
Dec 18th, 2002, 12:41 AM
#2
11/22/2002 is a valid date. What is the problem?
-
Dec 18th, 2002, 12:42 AM
#3
Thread Starter
Junior Member
It's not today's date. "somevariable" is the current amount of days after 1900, which I'm getting as 37580 from C++.
-
Dec 18th, 2002, 12:52 AM
#4
I think your somevariable is wrong because if I enter 365 instead of somevariable I get 1/1/1901 and if I use 730 I get 1/1/1902, both of which seem correct.
-
Dec 18th, 2002, 12:55 AM
#5
Hmmm. I think either the VB formula or C++ is not considering leap years. There have been about 25 leap years since 1900 and I think that that is the number of days you are off.
-
Dec 18th, 2002, 12:57 AM
#6
Thread Starter
Junior Member
It's the C++ thing. I don't think its considering leap years. If you try 1825 (365 * 5) it correctly returns 12/31/1904. Any ideas on how to fix it?
-
Dec 18th, 2002, 01:07 AM
#7
DateDiff("d", "1900/1/1", Now)
returns 37605
-
Dec 18th, 2002, 01:10 AM
#8
Thread Starter
Junior Member
Ok well do you know of any C++ DateDiff like functions. It's because the method being used in the C++ isn't considering leap years. I'm thinking of something like:
int days = (timestruct->tm_year * 365) + timestruct->tm_yday + int(timestruct->tm_year / 4);
if(timestruct->tm_mon < 2 && timestruct->tm_year % 4 == 0) //2 = March
{
days--;
}
Last edited by Drunken F00l; Dec 18th, 2002 at 01:15 AM.
-
Dec 18th, 2002, 01:19 AM
#9
-
Dec 18th, 2002, 01:21 AM
#10
Thread Starter
Junior Member
OK, that function should do good enough anyways. Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|