Click to See Complete Forum and Search --> : asp syntax issues


havey
07-26-2005, 02:56 PM
can someone lookover the code below and let me know as to why the aa variable does not work in the IF statments, thanks from a newbie!


<%
DIM iDay
iDay = DatePart("w", Date())

SELECT CASE iDay
Case "1" strDayName = "Sunday"
Case "2" strDayName = "Monday"
Case "3" strDayName = "Tuesday"
Case "4" strDayName = "Wednesday"
Case "5" strDayName = "Thursday"
Case "6" strDayName = "Friday"
Case "7" strDayName = "Saturday"
END SELECT

aa = FormatDateTime(Time, vbShortTime) ' display format 18:34
'response.write aa


If iDay = "6" AND aa = "15:10" then %>
<script language="JavaScript"><!--
if (document.images)
setTimeout('location.reload(true)',1000*60*3880);
else
setTimeout('location.href = location.href',1000*60*3880);
//--></script>
<%
response.write " Weekend Stop " & Date() & "..............." &Time()

ElseIf (iDay="1" OR iDay="2" OR iDay="3" OR iDay="4" OR iDay="5") AND (aa => "7:50") Then %>

<script language="JavaScript"><!--
if (document.images)
setTimeout('location.reload(true)',1000*60*1);
else
setTimeout('location.href = location.href',1000*60*1);
//--></script>

<%
response.write " Update successful........................" & Date() & "..............." &Time()

ElseIf (iDay="1" or iDay="2" or iDay="3" or iDay="4") AND (cc = "15:10") Then
%>

<script language="JavaScript"><!--
if (document.images)
setTimeout('location.reload(true)',1000*60*900);
else
setTimeout('location.href = location.href',1000*60*900);
//--></script>


<%
response.write " End Day Stop " & Date() & "..............." &Time()

End If %>

buntine
07-26-2005, 04:58 PM
What happens?

Your operator on the ElseIf should be >= rather than =>

Regards.

havey
07-27-2005, 12:53 PM
none of the if statements are satified, if i put an Else at the end of the IFs it will always choose the else no matter what day of week or time it is

buntine
07-27-2005, 06:53 PM
Well, it will only be caught if the time is 15:10 or 7:50. Otherwise, your if's will result false.

Regards.

havey
07-29-2005, 03:25 PM
I have optimized the code with a case statement - i dont have luck with ElseIfs

still having problems, no asp errors displayed, but also none of the response.writes display, any ideas?

iDay = DatePart("w", Date()) '1,2,3,4,5,6
aa = Cstr(FormatDateTime(Time, vbShortTime)) 'display format 18:34 as string
bb = "22:10"
cc = "4:50"

Select Case iDay

Case 6
If aa >= bb Then
response.write "WeekEnd Stop " & Date() & "..............." &Time()
ElseIf (aa >= cc AND aa < bb) Then
response.write "Update successful........................" & Date() & "..............." &Time()
End If

Case 2, 3, 4, 5
If aa >= bb Then
response.write "End Day Stop " & Date() & "..............." &Time()
ElseIf (aa >= cc AND aa < bb) Then
response.write "Update successful........................" & Date() & "..............." &Time()
End If

End Select

havey
07-29-2005, 03:53 PM
figured it out:

aa = Cstr(FormatDateTime(Time, vbShortTime))
bb = Cstr(FormatDateTime("22:10", vbShortTime))
cc = Cstr(FormatDateTime("4:50", vbShortTime))