Twitter

Follow SQLQuill on Twitter

Subscribe

MN Pass

TSQL Tip O’ the Week – 8/16/11 – DateDiff

This weeks tip:

The DATEDIFF function is very simple and very powerful…

With it you can:

  • Count the days, weeks, years, since an event occurred (I’ve done this to impress my kids by telling them how many day old they are)

Select DATEDIFF(D, ‘1/1’11’, GETDATE()) –How many days since New Years Day 2011

  • Count the minutes, seconds, milliseconds, microseconds, nanoseconds until something occurs (I’ve counted down until Friday at 5 PM a few times as well as to the day I retire).

Select DATEDIFF(D, GETDATE(), ‘1/1’15’) –How many days until the Coach Kill leads the Gopher Nation to the Rose Bowl

 

Previous Tips O’ the Week

Stopwatch

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>