Calculating intervals between two dates (Interesting Example) Header

Calculating intervals between two dates (Interesting Example)

  [Call : 201-377-9031 (US) 0207-096-0627 (UK)]          About Us : Support : Contact  : Site Map 
    Home | Products | Hosting | Services | Resources | FAQ
HomeCalculating intervals between two dates (Interesting Example)ResourcesCalculating intervals between two dates (Interesting Example)
Home Products Hosting Services Resources FAQ
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())%>).

 
Source Code






Countries where our products are used.


 Copyright © 2006 ScriptMate. Calculating intervals between two dates (Interesting Example) 
Password Protection :: Church Membership Software :: Membership Management Software
Membership Software :: User Management :: Classified Ads Software :: FAQ Management Software :: Free VBScript Resource
Bunk Beds :: Cribs :: Cradles Kids Furniture :: New Born Baby Furniture :: Baby Furniture