Period of time between two different dates
 
 
Code Result
I was borned on 1/1/1900. How old I am? 
<% Mydate="1/1/1900" %>
Years form <% =Mydate %>: <% =DateDiff("yyyy", Mydate, Date) %>
I was borned on 1/1/1900. How old I am?
Years form1/1/1900: 108
I had an accident on 30/11/2001. 
How many days I have been sleeping?
<% Mydate="30/11/2001" %>
Days form <% =Mydate %>: <% =DateDiff("D", Mydate, Date) %>
 
I had an accident on 30/11/2001. 
How many days I have been sleeping?
Days form30/11/2001: 2478
Days in next 6 years: 
<% =DateDiff("D", Date, dateAdd ("yyyy",6,Date)) %>
Days in next 6 years: 
2191
<% Mydate="4/9/2005" %>
Days form now to <% =Mydate %>: <% =DateDiff("D", Date, Mydate) %>
Days form now to 4/9/2005: -1252
Seconds since midnight: <% =Timer %> Seconds since midnight: 29203.15

Date intervals constants used in the table above and some more.

Time period Constant
Year "yyyy"
Quarter "q"
Month "m"
Day of year "y"
Day "D"
Weekday "w"
Week of the year "ww"
Hour "h"
Minute "n"
Second "s"

 

AspTutorial.info.