Douglas Osborne-229812 (6/21/2016)
Wouldn't that work in 2400 - not 4000? Divisible by 4 but not 400?
No, that would become '29-feb-2' which translates as '2002-02-29'.
Only 22 dates will successfully convert in the datetime2 date range.
SELECT n FROM (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0))E(n)
SELECT a.n FROM E a, E b
SELECT a.n FROM E2 a, E2 b
SELECT ROW_NUMBER() OVER(ORDER BY (SELECT NULL)) n
SELECT DATEADD( dd, -1, DATEADD( YY, n, CAST( '00010301' as datetime2)))
WHERE (1 + n) % 100 = (1 + n) / 1000
AND DAY(DATEADD( dd, -1, DATEADD( YY, n, CAST( '00010301' as datetime2)))) = 29;
Luis C.How to post data/code on a forum to get the best help: Option 1 / Option 2
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?