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

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

Tipple
Guest
Posts: n/a

 10-15-2003

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)
wend

Thanks

Ray at
Guest
Posts: n/a

 10-15-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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)
> wend
>
>
>
> Thanks
>
>
>
>
>

Tipple
Guest
Posts: n/a

 10-16-2003

Thank you.

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >
> > 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)
> > wend
> >
> >
> >
> > Thanks
> >
> >
> >
> >
> >

>
>