SearchSearch   MemberlistMembers   RegisterRegister   ProfileProfile   Log inLog in 

Calculating How Many Days Until a Pre-Defined Recurring Date

 
Post new topic   Reply to topic    Open Hosting Internet Solutions Forum Index -> Articles and Tutorials -> Server Side Web Development
View previous topic :: View next topic  
Author Message
Mark Voss
Divine Being


Joined: 19 Jun 2002
Posts: 4946
Location: Cardiff, UK

PostPosted: Mon Feb 27, 2006 10:35 am    Post subject: Calculating How Many Days Until a Pre-Defined Recurring Date Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Open Hosting Internet Solutions Forum Index -> Articles and Tutorials -> Server Side Web Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2.0.11 © 2001, 2002 phpBB Group
FAQClick here for help using the phpBB forum