<%@ language=VBScript %>

<% option explicit %>

 

 

<%

'Filename:

'Purpose:

'Arguments: 'Author:

'Revised:

 

dim dtCurrDate

dim dtCalcDate

dim dtSelectedDate

dim dtTemp

dim sExcludeList

dim iDays 'counts the number of valid days between the two dates

dim dtDate

dim iDOW

dim sFactor

dim sFactorName

 

sFactor = request.form("FACTORX")

sExcludeList = Request.Form("EXCLUDE")

 

dtCurrDate = date()

dtSelectedDate = request.form("MONTH") & "/" & request.form("DAY") & "/" & request.form("YEAR")

dtCalcDate = dtSelectedDate

 

 

%>

<html>

 

<head>

<title>Time Interval Calculation Results</title>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<meta name="description" content="Page display the results of Lab 4 that demonstrates the ASP Request.Form collection.">

 

</head>

 

<body bgcolor="#ffffff">

 

<h1>Time Interval Calculation Results</h1>

<p>

 

<%

if not ISDATE(dtCalcDate) then

   response.write "Not a valid date. Please <a href='default.htm'>try again</a>."

else

   ' need to figure earliest date

   if DATEDIFF("s",dtCalcDate,dtCurrDate) > 0 then

       'Swap values

       dtTemp = dtCalcDate

      dtCalcDate = dtCurrDate

      dtCurrDate = dtTemp

   end if

 

   if LEN(sExcludeList) = 0 then

       iDays = DATEDIFF("d",dtCalcDate,dtCurrDate)    

   else

       iDays = 0

       for dtDate = dtCurrDate to dtCalcDate

          iDOW = Weekday(dtDate)

          if INSTR(sExcludeList,iDOW) = 0 then

             iDays = iDays + 1

          end if

       next

   end if

 

   Select Case UCASE(sFactor)

       Case "YYYY"

          sFactorName = "Years"

          iDays = iDays/365

       Case "M"

          sFactorName = "Months"

          iDays = iDays/30

       Case "W"

          sFactorName = "Weeks"

          iDays = iDays/7

       Case "D"

          sFactorName = "Days"

          iDays = iDays

   End Select

 

   Response.Write "<p>Date Selected: " & CSTR(dtSelectedDate) & "<br>"

   Response.Write "Current Date: " & CSTR(date) & "<br>"

   Response.write "The approximate time interval is " & CSTR(FORMATNUMBER(iDays,1)) & " " & sFactorName & ".</p>"

   response.write "<a href='default.htm'>Return to base page</a>"

 

 

end if

 

 

%>

 

</p>

<hr>

<p>CSC123 Lab 4, <a href="mailto:chris@valtara.com">Chris Allen</a>&nbsp;&nbsp;&nbsp;

<a href="http://valtara.com/csc123/">http://valtara.com/csc123/</a>&nbsp;<br>

Last Updated: <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%B %d, %Y"

-->

</p>

</body>

</html>