Countdown to Date

Another trick you can do with dates is to display a countdown to a certain date.  Let’s say you wanted to display a countdown to New Years Day in the year 2100.  Here is how to do it:

<%
DIM strDate
strDate = Date()

Response.Write DateDiff(“d”, strDate, #1/1/2100#) & ” : ”
Response.Write DateDiff(“m”, strDate, #1/1/2100#) & ” : ”
Response.Write DateDiff(“yyyy”, strDate, #1/1/2100#)
%>

This displays the countdown in days, months, and years between today and 1/1/2100 and today in this format.  30922 : 1016 : 85

< Back to ASP Scripts