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

Posting Permissions

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