Print Page | Close Window

Date Difference

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=4850
Printed Date: 30 March 2026 at 3:03pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Date Difference
Posted By: janice
Subject: Date Difference
Date Posted: 07 August 2003 at 8:28pm

Please help to get this to work.

My display screen is set up like this:

        Play Date               endDate     Diff
A       07/20/2003              
B       07/21/2003
C       07/22/2003

A       07/26/2003              
B       07/27/2003
C       07/28/2003




When I run this code snipp below,
I expect to see the difference between Play Date and End Date and  then that difference appears in Diff Column

The date is not getting calculated properly.

First, in each row, I get same date difference.
For instance, row one, if the endDate is 08/05/2003,
 I expect to see 18 in the first A-row, 17 in first B-row, and 16 in
first C-row.

I am getting 18 in all 3 rows.

Same with second row of data.
In second row, for instance starting with 07/26/2003: if the end date is 08/05/2003, all values for diff are the same.
They are all number 11

The 3 difference PlayDates are the dates each row is expected to

play their games.

The endDate is the actual date each row plays their games.

What we are trying to determine is how many days it took each row to play their games.

For instance, if playDate1 is 08/03/2003 and endDate is 08/08/2003, we would like to print a message that says " 5 days past playdate.

So far, none of them is working.


Below is my code snippet.


Dim days
Dim PlayDate1, PlayDate2, PlayDate3
Dim enddate

Do While Not rst.EOF
PlayDate1= dateAdd("d", 1,rst("endDate"))
PlayDate2= dateAdd("d", 2,rst("endDate"))
PlayDate3= dateAdd("d", 3,rst("endDate"))
enddate = rst("actual")

If playDate1 > endDate  Then
    days = DateDiff("d", PlayDate1, enddate)
ElseIf playDate2   > endDate   Then
    days = DateDiff("d", PlayDate2, enddate)
ElseIf playDate3   > endDate   
  days = DateDiff("d", PlayDate3, enddate)

End If

Response.Write "<font color=""#000000"">" & days & " days past play date</font>"  

  rst.MoveNext
Loop

 

Thanks for your help!




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net