Mega Code Archive

 
Categories / MSSQL / Date Timezone
 

DATEDIFF(d, @thisdate, @nextmonth) Days between

3> DECLARE @thisdate datetime, @nextmonth datetime 4> 5> SET @thisdate = GETDATE() 6> SET @nextmonth = DATEADD(m, 1, GETDATE()) 7> 8> SELECT CONVERT(varchar, @thisdate, 101) 'Today', 9>     CONVERT(varchar, @nextmonth, 101) 'One month from today', 10>     DATEDIFF(d, @thisdate, @nextmonth) 'Days between' 11> GO Today                          One month from today           Days between ------------------------------ ------------------------------ ------------ 10/12/2006                     11/12/2006                               31 (1 rows affected) 1>