Forums
This topic is locked
Conditional Statement That Sets Variables?
Posted 08 Aug 2008 05:19:29
1
has voted
08 Aug 2008 05:19:29 Sirena Ferris posted:
Hello! I am in need of an assist. I am trying to create a conditional statement that will create variables, but I am running into some problems. The statement needs to check to see if the time is between 3:00pm on a Thursday and between 3:00pm on the following Friday. so Thursday 3:00pm - Friday 3:00pm
I know that I have to incorporate a code that can determine the days of the week and the one I have is:
<%
Dim strDay
Dim strMonth
strDay=(weekday(date))
Select Case strDay
case 1 Response.write("Sunday"
case 2 Response.write("Monday"
case 3 Response.write("Tuesday"
case 4 Response.write("Wednesday"
case 5 Response.write("Thursday"
case 6 Response.write("Friday"
case 7 Response.write("Saturday"
End Select
%>
But I cannot figure out a way to manipulate this code to get it to set either a session variable that will indicate we have the right day (so then I can create another conditional statement relative to time) or how to make it check if it is between thursday at 3 and friday at 3 at the same time. Any suggestions would be extremely helpful!!
Thanks in advance,
Sirena
Replies
Replied 08 Aug 2008 18:11:12
08 Aug 2008 18:11:12 Andrew Watson replied:
Hi Sirena...
Theres a hundred ways to do this..heres a quick and easy way..
<pre id=code><font face=courier size=2 id=code>
dim dat_date
dat_date = date()
int_weekday = weekday(dat_date)
dat_time = time()
if int_weekday = 5 then
'Its Thursday...so check the times later then 15:00
if dat_time >= cdate("15:00" then
str_result = "in the timeframe."
else
str_result = "not in the timeframe."
end if
elseif int_weekday = 6 then
'Its Friday...so check the times earlier then 15:00
if dat_time < cdate("15:00" then
str_result = "in the timeframe."
end if
else
str_result = "not in the timeframe."
end if
response.write str_result</font id=code></pre id=code>
:: Son, im Thirty.... ::
Theres a hundred ways to do this..heres a quick and easy way..
<pre id=code><font face=courier size=2 id=code>
dim dat_date
dat_date = date()
int_weekday = weekday(dat_date)
dat_time = time()
if int_weekday = 5 then
'Its Thursday...so check the times later then 15:00
if dat_time >= cdate("15:00" then
str_result = "in the timeframe."
else
str_result = "not in the timeframe."
end if
elseif int_weekday = 6 then
'Its Friday...so check the times earlier then 15:00
if dat_time < cdate("15:00" then
str_result = "in the timeframe."
end if
else
str_result = "not in the timeframe."
end if
response.write str_result</font id=code></pre id=code>
:: Son, im Thirty.... ::
Replied 08 Aug 2008 18:26:19
08 Aug 2008 18:26:19 Sirena Ferris replied:
That is pretty much exactly what I am looking for, but I still have one problem that has been bugging me. Instead of doing a response.write saying that it is in the timeframe, can I instead set a session variable called satshipping (for example) to Yes or No. I have been trying to integrate session variables into the if then and that is where I am really lost. Thanks for all your help those far.