Tuesday, 29 November 2011

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 like this:
32174 : 1058 : 89

No comments:

Post a Comment