Subject: complicated if else statement help needed
Posted By: cmt9000 Post Date: 12/13/2006 10:43:26 AM
Hey guys,

I have a if then else statement that's giving me trouble. I need to display an icon on a website if a certain date(testdate) is:

-today
-yesterday
-tomorrow(if and only if it's now 5pm or later)
-if today is friday, saturday, sunday and the testdate is friday, saturday, sunday, or monday



Take a look below and see if you can figure out a better way to do this:




today = DateSerial(Year(Now), Month(Now), Day(Now))
todayhour = hour()
yesterday = DateAdd("d", -1, today)
tomorrow = DateAdd("d", 1, today)

testdate = completedate
testdate = DateSerial(Year(testdate), Month(testdate),Day(testdate))
'1 displays the icon
'0 doesn't display the icon

If testdate = today OR testdate = yesterday OR (testdate = tomorrow AND todayhour >= 17) Then                                                                
                 
        DisplayCaseSummaryIcon = 1
    Else 
    
        If WeekDay(today) <> 6 And Weekday(today) <> 7 And Weekday(today) <> 1 Then            
            
            DisplayCaseSummaryIcon = 0
        Else
                       If testdate = 6 Or testdate = 7 Or testdate = 1 Or testdate = 2 Then 
            DisplayCaseSummaryIcon = 1                                                                        
           End If

    End If



Thanks

Reply By: mat41 Reply Date: 12/13/2006 5:34:50 PM
I understand you first three asks (-today, -yesterday,-tomorrow(if and only if it's now 5pm or later)) to achieve this you could:

'note: we use dd/mm/yyyy here in aussie
dim testDate
testDate = "15/12/2006"
if (cDate(testDate) = (date()-1)) then
   response.write "show image for testDate being one day before today"
elseif (cDate(testDate) = (date())) then
   response.write "show image for testDate being today"
elseif ((cDate(testDate) = (date()+1)) AND (hour(now()) >= 17)) then
   response.write "show image where testDate is one day after today + its past 5pm today"
end if


however fail to understand the following:
;;;-if today is friday, saturday, sunday and the testdate is friday, saturday, sunday, or monday


Wind is your friend
Matt

Go to topic 53594

Return to index page 94
Return to index page 93
Return to index page 92
Return to index page 91
Return to index page 90
Return to index page 89
Return to index page 88
Return to index page 87
Return to index page 86
Return to index page 85