Professional Web Applications Themes

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

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...

  1. #1

    Default 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





    Tipple Guest

  2. #2

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

    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" <emailnot-an-email-address.com> wrote in message
    news:Oc0GrWzkDHA.3316tk2msftngp13.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
    >
    >
    >
    >
    >

    Ray at Guest

  3. #3

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


    Thank you.


    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:eSfOVgzkDHA.3320tk2msftngp13.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" <emailnot-an-email-address.com> wrote in message
    > news:Oc0GrWzkDHA.3316tk2msftngp13.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
    > >
    > >
    > >
    > >
    > >
    >
    >

    Tipple Guest

Similar Threads

  1. DatePart, 24-hour clock
    By gary@4reach.com in forum Coldfusion - Advanced Techniques
    Replies: 1
    Last Post: June 26th, 04:56 PM
  2. How to SELECT DatePart as a new Variable
    By Gahiggidy in forum Macromedia ColdFusion
    Replies: 0
    Last Post: June 30th, 06:25 PM
  3. DateAdd
    By kt03 in forum Coldfusion - Getting Started
    Replies: 8
    Last Post: February 17th, 10:01 PM
  4. DatePart query
    By David in forum ASP
    Replies: 3
    Last Post: September 17th, 01:11 PM
  5. Using DatePart and DateDiff together in a query
    By Patty in forum Microsoft SQL / MS SQL Server
    Replies: 1
    Last Post: June 30th, 07:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139