Using DateDiff function in SQL Statement

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

 

You may use DateDiff function in an SQL statement to get the number of date and/or time between two dates. You may calculate days between two different date. The return number of DateDiff function can be year, month, day, hour, minute, second ....

An example of using DateDiff function in a real ASP script :

 

<% set cn = server.createobject("adodb.connection")

cn.open "Provider=SQLOLEDB;Server=localhost;User ID=SA;Password=;Database=newsTable;"

set rc = cn.execute("select datediff(day, pubDate, endDate) from news where newsID = 12")

response.write rc(0)

%>

 


Custom Search



Gazatem Technologies Active News Manager


page counter

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