Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 13th, 2006, 11:43 AM
Registered User
 
Join Date: Dec 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default complicated if else statement help needed

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:



Code:
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

 
Old December 13th, 2006, 06:34 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Complicated Insert Statement jackie25 SQL Server ASP 1 May 31st, 2006 09:08 AM
Seemingly Complicated Query help needed krashed SQL Language 5 March 31st, 2006 01:02 AM
Nested IIF Statement Help Needed Corey Access 4 November 17th, 2005 10:19 AM
Help needed in constructing create table statement method Access VBA 0 April 28th, 2005 11:04 AM
help needed with a SQL select statement problem wslyhbb Java Databases 1 August 14th, 2003 07:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.