|
-
Feb 17th, 2007, 09:18 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] DateAdd: Crossing Midnight
Can anyone explain why this happens and how to get around it:
This code:
VB Code:
DateAdd("s", 1, #12:59:59 PM#)
Returns this:
1:00:00 PM
Not this:
00:00:00 AM
-
Feb 17th, 2007, 09:23 PM
#2
Re: DateAdd: Crossing Midnight
That's what it should be doing......
-
Feb 17th, 2007, 09:29 PM
#3
Frenzied Member
Re: DateAdd: Crossing Midnight
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#
-
Feb 17th, 2007, 09:37 PM
#4
Re: DateAdd: Crossing Midnight
Try DateAdd("s", 1, #11:59:59 PM#)
I don't know about you, but I get long ago and far away.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Feb 17th, 2007, 11:05 PM
#5
Re: DateAdd: Crossing Midnight
If you change it to 11:59:59 AM then it goes to 12:00:00 it will never go to 0:00:00
-
Feb 18th, 2007, 12:16 AM
#6
Thread Starter
Hyperactive Member
Re: DateAdd: Crossing Midnight
You're right about 12:59PM to 1 PM. My goof.
However,
VB Code:
DateAdd("s", 1, #11:59:59 PM#)
returns:
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.
-
Feb 18th, 2007, 12:18 AM
#7
Thread Starter
Hyperactive Member
Re: DateAdd: Crossing Midnight
You're right about 12:59PM to 1 PM. My goof.
However, as A142 points out:
VB Code:
DateAdd("s", 1, #11:59:59 PM#)
returns:
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.
-
Feb 18th, 2007, 12:41 AM
#8
Hyperactive Member
Re: DateAdd: Crossing Midnight
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#))
-
Feb 18th, 2007, 09:01 PM
#9
Thread Starter
Hyperactive Member
Re: DateAdd: Crossing Midnight
Excellent. I think that'll do it. 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
|