469,903 Members | 2,126 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

dateAdd and datePart return 13, 14, 15 instead of 1, 2, 3


I'm trying to increment between the end of lunch and the end of the day. The
code below is returning a datePart of 13 instead of 1 (for 1:00:00 PM) and
14 instead of 2:00:00 PM etc..

If response.write just counter2 I get a real hour.
How can I return the actual hour datePart?
lunchStart = "12:00:00 PM"
lunchEnd = "1:00:00 PM"
dayEnd = "5:00:00 PM"
counter2 = cdate(lunchEnd)

while counter2 >= cdate(lunchEnd) AND counter2 <= cdate(dayEnd)
response.write datePart("h",counter2)
counter2 = dateAdd("h",1,counter2)
wend

Thanks

Jul 19 '05 #1
2 2337
I'd imagine this is to be expected, since if it returned 5 instead of 17,
that would be inaccurate, in my opinion. You can subtract 12 if the number
is greater than 12.

h = datepart("h", counter)
If n > 12 then h = h - 12

Ray at work

"Tipple" <em***@not-an-email-address.com> wrote in message
news:Oc**************@tk2msftngp13.phx.gbl...

I'm trying to increment between the end of lunch and the end of the day. The code below is returning a datePart of 13 instead of 1 (for 1:00:00 PM) and
14 instead of 2:00:00 PM etc..

If response.write just counter2 I get a real hour.
How can I return the actual hour datePart?
lunchStart = "12:00:00 PM"
lunchEnd = "1:00:00 PM"
dayEnd = "5:00:00 PM"
counter2 = cdate(lunchEnd)

while counter2 >= cdate(lunchEnd) AND counter2 <= cdate(dayEnd)
response.write datePart("h",counter2)
counter2 = dateAdd("h",1,counter2)
wend

Thanks


Jul 19 '05 #2

Thank you.
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:eS**************@tk2msftngp13.phx.gbl...
I'd imagine this is to be expected, since if it returned 5 instead of 17,
that would be inaccurate, in my opinion. You can subtract 12 if the number is greater than 12.

h = datepart("h", counter)
If n > 12 then h = h - 12

Ray at work

"Tipple" <em***@not-an-email-address.com> wrote in message
news:Oc**************@tk2msftngp13.phx.gbl...

I'm trying to increment between the end of lunch and the end of the day.

The
code below is returning a datePart of 13 instead of 1 (for 1:00:00 PM) and 14 instead of 2:00:00 PM etc..

If response.write just counter2 I get a real hour.
How can I return the actual hour datePart?
lunchStart = "12:00:00 PM"
lunchEnd = "1:00:00 PM"
dayEnd = "5:00:00 PM"
counter2 = cdate(lunchEnd)

while counter2 >= cdate(lunchEnd) AND counter2 <= cdate(dayEnd)
response.write datePart("h",counter2)
counter2 = dateAdd("h",1,counter2)
wend

Thanks



Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Wer | last post: by
3 posts views Thread by Annette Massie | last post: by
10 posts views Thread by Mika M | last post: by
1 post views Thread by sravanbakhsh | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.