Results 1 to 10 of 10

Thread: Date Problems

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2002
    Posts
    24

    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?

  2. #2

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2002
    Posts
    24
    It's not today's date. "somevariable" is the current amount of days after 1900, which I'm getting as 37580 from C++.

  4. #4

  5. #5

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Dec 2002
    Posts
    24
    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?

  7. #7

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Dec 2002
    Posts
    24
    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.

  9. #9

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Dec 2002
    Posts
    24
    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
  •  



Click Here to Expand Forum to Full Width