I always try to remember these functions but for some reason end up going to MSDN to find the actual function name and syntax.
DATEADD (datepart , number , date )
select DATEADD (mm, 1, getdate())
DATEDIFF ( datepart , startdate , enddate )
select DATEDIFF (hh, getdate(), '2013-04-16 00:11:11.00')
Table below is from MSDN, just to you everyone an overview of possible option to use
with these functions (along with any other DATE functions)
datepart | abbreviations |
year | yy, yyyy |
quarter | qq, q |
month | mm, m |
dayofyear | dy, y |
day | dd, d |
week | wk, ww |
hour | hh |
minute | mi, n |
second | ss, s |
millisecond | ms |
microsecond | mcs |
nanosecond | ns |
Hope this helps and as always good is my friend....
No comments:
Post a Comment