Friday, November 17, 2017

setting dates in T-SQL from magic strings

The dates here represent wide adoption of Gregorian calendar in Sweden and the comet Swift–Tuttle passing close to Earth:

SET @StartDate = (CASE WHEN @StartDate is null THEN '1753-01-01' ELSE
      @StartDate END)
SET @EndDate = (CASE WHEN @EndDate is null THEN '2126-08-05' ELSE
      @EndDate END)

 
 

'1753-01-01 00:00:00.000' is the long form.

No comments:

Post a Comment