Can anyone explain why this happens and how to get around it:
This code:
Returns this:VB Code:
DateAdd("s", 1, #12:59:59 PM#)
1:00:00 PM
Not this:
00:00:00 AM
Printable View
Can anyone explain why this happens and how to get around it:
This code:
Returns this:VB Code:
DateAdd("s", 1, #12:59:59 PM#)
1:00:00 PM
Not this:
00:00:00 AM
That's what it should be doing......
You're just past noon.
#12:59:59 PM# is 59 minutes and 59 seconds past noon.
Or 1 second to 1 PM.
Try:VB Code:
Print #12:30 AM# Print #12:30 PM#
Try DateAdd("s", 1, #11:59:59 PM#)
I don't know about you, but I get long ago and far away.
If you change it to 11:59:59 AM then it goes to 12:00:00 it will never go to 0:00:00
You're right about 12:59PM to 1 PM. My goof.
However,
returns:VB Code:
DateAdd("s", 1, #11:59:59 PM#)
12/31/1899
Not exactly what I expected (which is 12:00:00 AM). I'm trying to match time on a web server by reading a web page, parsing the time out of the HTML, then keeping track of the server's time by adding 1 second every, well, second.
So this is a problem.
You're right about 12:59PM to 1 PM. My goof.
However, as A142 points out:
returns:VB Code:
DateAdd("s", 1, #11:59:59 PM#)
12/31/1899
Not exactly what I expected (which is 12:00:00 AM). I'm trying to match time on a web server by reading a web page, parsing the time out of the HTML, then keeping track of the server's time by adding 1 second.
So this is a problem.
I had the same problem before.
Either add a date to your time string i.e.
VB Code:
DateAdd("s", 1, #18/02/2007 11:59:59 PM#)
or
use the TimeValue function for your result i.e.
VB Code:
MsgBox TimeValue(DateAdd("s", 1, #11:59:59 PM#))
Excellent. I think that'll do it. Thanks!