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

Discussion in 'ASP General' started by Tipple, Oct 15, 2003.

  1. Tipple

    Tipple Guest

    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
     
    Tipple, Oct 15, 2003
    #1
    1. Advertising

  2. Tipple

    Ray at Guest

    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" <> wrote in message
    news:...
    >
    > 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
    >
    >
    >
    >
    >
     
    Ray at, Oct 15, 2003
    #2
    1. Advertising

  3. Tipple

    Tipple Guest

    Thank you.


    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:...
    > 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" <> wrote in message
    > news:...
    > >
    > > 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
    > >
    > >
    > >
    > >
    > >

    >
    >
     
    Tipple, Oct 16, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt Tapia

    DateAdd Function and error BC30451

    Matt Tapia, Aug 13, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    2,187
    Chris R. Timmons
    Aug 13, 2003
  2. =?Utf-8?B?QWFyYW43Ng==?=

    datepart function

    =?Utf-8?B?QWFyYW43Ng==?=, Nov 3, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,781
    Bruce Barker
    Nov 3, 2005
  3. David

    DatePart query

    David, Sep 16, 2003, in forum: ASP General
    Replies:
    3
    Views:
    185
    Tom B
    Sep 17, 2003
  4. Chumley the Walrus
    Replies:
    3
    Views:
    144
    Chumley the Walrus
    Aug 27, 2004
  5. le0

    DatePart

    le0, Aug 11, 2006, in forum: ASP General
    Replies:
    1
    Views:
    121
Loading...

Share This Page