Comparing Dates

posted by Dotnetindex date: Thursday, May 22, 2008 category: ASP
  Featured Story | Printable View | Email It | Comments | Write Comment

In this tutorial we will compare dates. We will use DateDiff function. You may compare any two valid dates calculation year, day, month, week, minute ans seconds. Here is an example :

<%
date1 = "10/05/2003"
date2 = "1/13/2006"

strResult = DateDiff("yyyy", date1, date2) ' compare and get the result in year
strResult = DateDiff("D", date1, date2) ' compare and get the result in day

%>

Here is the complete constants table



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"


Custom Search



Gazatem Technologies Active News Manager


page counter

Listed with 411asp.net
Listed with 4aspin.com
PHP, ASP, .NET, JSP Resources, Reviews