1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Problem with DateDiff in *.vbs - time zones?

Discussion in 'Visual Basic ( VB )' started by Iona, Apr 16, 2008.

  1. Iona

    Iona New Member

    Joined:
    Sep 30, 2007
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    Hi All,

    I've narrowed down an application problem to a strange "DateDiff" outcome.

    The following sole lines of code in a *.vbs file:
    Dim iDaysToGo
    iDaysToGo = DateDiff("h", Now, "01/08/08")
    MsgBox "Now = " & Now & Chr(10) & "01-Aug-08 was " & (iDaysToGo * -1) & " days ago. ", , "TIME TEST"

    ...produced this result today in UK (PASS):
    Now = 16/04/2008 11:20:06
    01-Aug-08 was -107 days ago

    ...but this result in today Canada (FAIL):
    Now = 2008-04-16 08:21:21
    01-Aug-08 was 2443 days ago

    Any ideas? Is this a Windows regional setting? Note the date is formatted in reverse.

    Thanks,

    JB
     

Share This Page