using datediff function in sql

Posted on May 14, 2008. Filed under: Sql Server |

 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)

Make a Comment

Make A Comment: ( None so far )

blockquote and a tags work here.

    About

    Hi,I am Suresh Sharma(MCP) from Gorakhpur , UP, India.I have work on .net technology from 2 years. Key skills-Asp.net 2.0,3.5, Sql 2005,2000. Ajax.net 1.1,C#.net

    RSS

    Subscribe Via RSS

    • Subscribe with Bloglines
    • Add your feed to Newsburst from CNET News.com
    • Subscribe in Google Reader
    • Add to My Yahoo!
    • Subscribe in NewsGator Online
    • The latest comments to all posts in RSS
    • Subscribe in Rojo

    Meta

Liked it here?
Why not try sites on the blogroll...