Hi All,
i remember somebody posted a question like this a while ago but i don't remember any answer appearing, and i can't find the thread now. I also know i've posted that its better to use DateAdd in the past - but i don't know why, i think i remember reading that it's more accurate. Simple addition and subtraction works much faster and seems just as accurate eg
the latter is about 50 times faster in the tests i've done so although Timer isn't all that accurate i refuse to believe it's that innacurate. The only reason i can see is that it's (marginaly) easier to read and handy for adding months - is there any other better reason than that?
Many thanks in advance
Drew
[This message has been edited by KDg (edited 08-14-2001).]
i remember somebody posted a question like this a while ago but i don't remember any answer appearing, and i can't find the thread now. I also know i've posted that its better to use DateAdd in the past - but i don't know why, i think i remember reading that it's more accurate. Simple addition and subtraction works much faster and seems just as accurate eg
Code:
Sub gret()
Dim x As Double
Dim s As Double
Dim myDate As Date
myDate = #1/1/1899#
x = Timer
For s = 1 To 300001
myDate = DateAdd("n", 30, myDate)
Next
Debug.Print Format(Timer - x, "#######.#####") & " " & Format(myDate, "DD/MM/YYYY HH:NN:SS")
myDate = #1/1/1899#
x = Timer
For s = 1 To 300001
myDate = myDate + 1 / 48
Next
Debug.Print Format(Timer - x, "#######.#####") & " " & Format(myDate, "DD/MM/YYYY HH:NN:SS")
End Sub
the latter is about 50 times faster in the tests i've done so although Timer isn't all that accurate i refuse to believe it's that innacurate. The only reason i can see is that it's (marginaly) easier to read and handy for adding months - is there any other better reason than that?
Many thanks in advance
Drew
[This message has been edited by KDg (edited 08-14-2001).]