Mark Voss Divine Being

Joined: 19 Jun 2002 Posts: 4946 Location: Cardiff, UK
|
Posted: Mon Feb 27, 2006 10:35 am Post subject: Calculating How Many Days Until a Pre-Defined Recurring Date |
|
|
Calculating How Many Days Until a Pre-Defined Recurring Date (ASP)
In this example I've used Christmas day as the annually recurring date.
All you need to do is to is ammend the recurring_date and the text Christmas day (on the two Response.Write lines) in the script below to your annually recurring date.
| Code: | <%
Dim recurring_date, days_to_recurring_date
recurring_date="25/12/2006"
days_to_recurring_date = DateDiff("d",Date,recurring_date)
Do While days_to_recurring_date < 0
recurring_date = DateAdd("yyyy",1,recurring_date)
days_to_recurring_date = DateDiff("d",Date,recurring_date)
Loop
If DateDiff("d",Date,recurring_date) > 0 Then
Response.Write "It is " & days_to_recurring_date & " days until Christmas day"
Else
Response.Write "It is Christmas day today."
End If
%> |
The script will always output the number of days until next Christmas Day even if the recurring date you set is in the past. |
|