Wednesday, May 14, 2008

using datediff function in sql

select datediff(year,'Nov 30 2001',getdate()) as diffyear 

select datediff(month,'Nov 30 2001',getdate())as diffmonth
 select datediff(day,'Nov 30 2001',getdate()) as diffdaydiffyear

 diffyear

-----------

 7 (1 row(s) affected)

diffmonth

-----------

78(1 row(s) affected)

diffday

----------

2357(1 row(s) affected)

No comments :

Post a Comment

AJAX, asp, Asp.net, asp.net and sql server security, Asp.net IntemIndex, C#, Css, DataBinder.Eval, DataKeyNames, Datalist, Datapager, DataSet, DataTable, DropDownList, FindControl, gridview, JavaScript, jquery, Listview, Paging, Regex, RegularExpression, Repeater, Server side validation, Sql Server, timer, timercallback, Validation, XML, xmlnode, XPath