Professional Web Applications Themes

For loop using time - ASP

I think you could do: For i = 0 to 23 Response.write "<option value=" & i & ">" & FormatDateTime(i/48, 3) Next Because: 0/48 = midnight 1/48 = 12:30 AM (1/48th of the day has passed.) 2/48 = 1:00 AM (2/48ths of the day have passed.) .... Ray at work "Shawn" <sfergus2cscc.edu> wrote in message news:136c01c37ebf$f7a69a50$a401280aphx.gbl... > Is there a way to use a for loop to print every hour from > 12:00AM to 12:00PM in half hour intervals. > > desired output > 12:00AM > 12:30AM > 1:00AM > 1:30AM > ... > ... > ... > 11:30PM > ...

  1. #1

    Default Re: For loop using time

    I think you could do:

    For i = 0 to 23
    Response.write "<option value=" & i & ">" & FormatDateTime(i/48, 3)
    Next

    Because:

    0/48 = midnight
    1/48 = 12:30 AM (1/48th of the day has passed.)
    2/48 = 1:00 AM (2/48ths of the day have passed.)
    ....

    Ray at work


    "Shawn" <sfergus2cscc.edu> wrote in message
    news:136c01c37ebf$f7a69a50$a401280aphx.gbl...
    > Is there a way to use a for loop to print every hour from
    > 12:00AM to 12:00PM in half hour intervals.
    >
    > desired output
    > 12:00AM
    > 12:30AM
    > 1:00AM
    > 1:30AM
    > ...
    > ...
    > ...
    > 11:30PM
    >
    > So far I have this:
    > <%
    > For i = 0 To DateDiff("h", "0:00AM", "23:00PM")
    > Response.Write "<option value="" i & "">" & timeserial(i,
    > 0, 0)
    > Next
    > %>
    >

    Ray at Guest

  2. #2

    Default Re: For loop using time

    Dim StartTime
    Dim iLoop
    Dim TempTime

    StartTime=TimeSerial(0,0,0) 'Midnight

    for iLoop = 0 to 48 '48 half-hours in a day
    TempTime=DateAdd("n",30*iLoop,StartTime)
    Response.write "<option value=""" & TempTime & """>" &
    FormatDateTime(TempTime,vbLongTime) & "</option>" & vbCrLf
    Next


    "Shawn" <sfergus2cscc.edu> wrote in message
    news:136c01c37ebf$f7a69a50$a401280aphx.gbl...
    > Is there a way to use a for loop to print every hour from
    > 12:00AM to 12:00PM in half hour intervals.
    >
    > desired output
    > 12:00AM
    > 12:30AM
    > 1:00AM
    > 1:30AM
    > ...
    > ...
    > ...
    > 11:30PM
    >
    > So far I have this:
    > <%
    > For i = 0 To DateDiff("h", "0:00AM", "23:00PM")
    > Response.Write "<option value="" i & "">" & timeserial(i,
    > 0, 0)
    > Next
    > %>
    >

    Tom B Guest

Similar Threads

  1. [PHP] Setting execution time for a loop
    By Mike Ford in forum PHP Development
    Replies: 1
    Last Post: September 10th, 11:51 AM
  2. Setting execution time for a loop
    By Zavaboy in forum PHP Development
    Replies: 2
    Last Post: September 10th, 10:25 AM
  3. elegant way of doing something else the last time through a loop?
    By Petre Agenbag in forum PHP Development
    Replies: 7
    Last Post: July 15th, 03:13 PM
  4. Replies: 0
    Last Post: July 15th, 03:13 PM
  5. Loop for a period of time.
    By Mamper webforumsuser@macromedia.com in forum Macromedia Director Basics
    Replies: 3
    Last Post: July 11th, 04:14 AM

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