Resources
| Calculating intervals between two dates (Interesting Example) |
| Posted by : Amit Agarwal |
Total Hits : 19592 |
The DateDiff() function returns the value of intervals between two dates. You can use many timeintervals with it as explained in detail in the code below. You can use it in the following format.
DateDiff(timeinterval, date1, date2 [ , firstdayofweek [, firstweekofyear ]])
timeinterval is the time interval options as in the code below, date1 and date2 are valid date expressions to be evaluated and firstdayofweek and firstweekofyear are optional values to specify the first day of the week and first week of the year.
|
|
|
Get the Source Code.
<%@ Language=VBScript %>
<% 'Assign Tempdate a value of any date to be used with DateDiff() function tempdate = "29/11/00" %>
Using "YYYY" timeinterval will give you Years (<%=datediff("YYYY",tempdate, now())%> ),
Using "Q" timeinterval will give you Quarter Years (<%=datediff("Q",tempdate, now())%>).
Using "M" timeinterval will give you Months (<%=datediff("M",tempdate, now())%>).
Using "WW" timeinterval will give you Weeks (<%=datediff("WW",tempdate, now())%>).
Using "D" timeinterval will give you Days (<%=datediff("D",tempdate, now())%>).
Using "H" timeinterval will give you Hours (<%=datediff("H",tempdate, now())%>).
Using "N" timeinterval will give you Minutes (<%=datediff("N",tempdate, now())%>).
Using "S" timeinterval will give you Seconds (<%=datediff("S",tempdate, now())%>).
|
|
|
|
 |
|
 |