Time() range

L

le0

Hello Guys,

I have this dropdown box and the options is TimeShift (6a-2pm, 2p-10p, 10p-6a ), im getting this data in a table (Acess DB) . My problem is how can i display (option selected) the actual shift based on the actual time.

Code:

<td width="100" height="5"><select size="1" name="ddShift">

<%Do While Not rstShift.EOF%>
<option value="<%=rstShift.Fields("ShiftID").Value%>"><%=rstShift.Fields("Shift").Value%></option>
<%
rstShift.Movenext
Loop
%>

or can i do it manually, but the problem is the <Condition statement>, im using "Between" like querying a date range in a database but it doesnt work. How can i get the range in Time()? Please Helpppp...

<%if <Condition> then%>
<option selected value="A"><%="6am-2pm"%></option>
<%end if%>

btw im using Frontpage and ASP Classic
 
M

Mike Brind

le0 said:
Hello Guys,

I have this dropdown box and the options is TimeShift (6a-2pm, 2p-10p, 10p-6a ), im getting this data in a table (Acess DB) . My problem is how can i display (option selected) the actual shift based on the actual time.

Code:

<td width="100" height="5"><select size="1" name="ddShift">

<%Do While Not rstShift.EOF%>
<option value="<%=rstShift.Fields("ShiftID").Value%>"><%=rstShift.Fields("Shift").Value%></option>
<%
rstShift.Movenext
Loop
%>

or can i do it manually, but the problem is the <Condition statement>, im using "Between" like querying a date range in a database but it doesnt work. How can i get the range in Time()? Please Helpppp...

<%if <Condition> then%>
<option selected value="A"><%="6am-2pm"%></option>
<%end if%>

btw im using Frontpage and ASP Classic

<%
Dim shift
shift=""
If DatePart("h", Now()) > 5 And DatePart("h", Now()) < 14 Then shift =
" selected"
If DatePart("h", Now()) > 13 And DatePart("h", Now()) < 22 Then shift =
" selected"
If DatePart("h", Now()) > 21 Or DatePart("h", Now()) < 6 Then shift = "
selected"
%>

<option value="A" <%=shift%>>6am-2pm</option>
<option value="B" <%=shift%>>2pm-10pm</option>
<option value="C" <%=shift%>>10pm-6am</option>
 
L

le0

Hey Mike thanks =)
I really apreciate that =)

Mike Brind said:
<%
Dim shift
shift=""
If DatePart("h", Now()) > 5 And DatePart("h", Now()) < 14 Then shift =
" selected"
If DatePart("h", Now()) > 13 And DatePart("h", Now()) < 22 Then shift =
" selected"
If DatePart("h", Now()) > 21 Or DatePart("h", Now()) < 6 Then shift = "
selected"
%>

<option value="A" <%=shift%>>6am-2pm</option>
<option value="B" <%=shift%>>2pm-10pm</option>
<option value="C" <%=shift%>>10pm-6am</option>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top