Skip to main content
added 380 characters in body
Source Link
mootinator
  • 1.2k
  • 1
  • 11
  • 17

T-SQL 166 185 Characters

CREATE PROCEDURE f29 (@d DATETIME) AS
DECLARE @i int
SET @i=YEAR(DATEADD(M,-2,@d)+3)
SET @i=@i+(4-@i%4)
IF @i%100=0 AND @i%400<>0 SET @i=@i+4
SELECT DATENAME(W,CAST(@i AS CHAR)+'-2-29')

I was already messing with T-SQL date functions, so I figured why not...

Original solution was incorrect...

Here's what I actually have to do to get that strategy to work:

CREATE PROCEDURE f29 (@d DATE) AS
DECLARE @i int
SET @i = YEAR(@d)
BEGIN TRY 
SET @i=YEAR(DATEADD(D, 3, DATEADD(M,-2,@d)))
END TRY
BEGIN CATCH
END CATCH
SET @i=@i+(4-@i%4)
IF @i%100=0 AND @i%400<>0 SET @i=@i+4
SELECT DATENAME(W,CAST(@i AS CHAR)+'-2-29')

T-SQL 166 185 Characters

CREATE PROCEDURE f29 (@d DATETIME) AS
DECLARE @i int
SET @i=YEAR(DATEADD(M,-2,@d)+3)
SET @i=@i+(4-@i%4)
IF @i%100=0 AND @i%400<>0 SET @i=@i+4
SELECT DATENAME(W,CAST(@i AS CHAR)+'-2-29')

I was already messing with T-SQL date functions, so I figured why not...

Original solution was incorrect...

T-SQL 166 185 Characters

CREATE PROCEDURE f29 (@d DATETIME) AS
DECLARE @i int
SET @i=YEAR(DATEADD(M,-2,@d)+3)
SET @i=@i+(4-@i%4)
IF @i%100=0 AND @i%400<>0 SET @i=@i+4
SELECT DATENAME(W,CAST(@i AS CHAR)+'-2-29')

I was already messing with T-SQL date functions, so I figured why not...

Original solution was incorrect...

Here's what I actually have to do to get that strategy to work:

CREATE PROCEDURE f29 (@d DATE) AS
DECLARE @i int
SET @i = YEAR(@d)
BEGIN TRY 
SET @i=YEAR(DATEADD(D, 3, DATEADD(M,-2,@d)))
END TRY
BEGIN CATCH
END CATCH
SET @i=@i+(4-@i%4)
IF @i%100=0 AND @i%400<>0 SET @i=@i+4
SELECT DATENAME(W,CAST(@i AS CHAR)+'-2-29')
...; deleted 1 characters in body
Source Link
mootinator
  • 1.2k
  • 1
  • 11
  • 17

T-SQL 166166 185 Characters

SELECT PROCEDURE f29 (@d DATE) AS DECLARE @i int SET @i=YEAR(DATEADD(M,-2,@d)) SET @i=@i+(4-@i%4) IF @i % 100 = 0 AND @i % 400 0 SET @i=@i+4 SELECT DATENAME(W, @i) I was already messing with T-SQL date functions, so I figured why not...
CREATE PROCEDURE f29 (@d DATETIME) AS
DECLARE @i int
SET @i=YEAR(DATEADD(M,-2,@d)+3)
SET @i=@i+(4-@i%4)
IF @i%100=0 AND @i%400<>0 SET @i=@i+4
SELECT DATENAME(W,CAST(@i AS CHAR)+'-2-29')

I was already messing with T-SQL date functions, so I figured why not...

Original solution was incorrect...

T-SQL 166 Characters

SELECT PROCEDURE f29 (@d DATE) AS DECLARE @i int SET @i=YEAR(DATEADD(M,-2,@d)) SET @i=@i+(4-@i%4) IF @i % 100 = 0 AND @i % 400 0 SET @i=@i+4 SELECT DATENAME(W, @i) I was already messing with T-SQL date functions, so I figured why not...

T-SQL 166 185 Characters

CREATE PROCEDURE f29 (@d DATETIME) AS
DECLARE @i int
SET @i=YEAR(DATEADD(M,-2,@d)+3)
SET @i=@i+(4-@i%4)
IF @i%100=0 AND @i%400<>0 SET @i=@i+4
SELECT DATENAME(W,CAST(@i AS CHAR)+'-2-29')

I was already messing with T-SQL date functions, so I figured why not...

Original solution was incorrect...

Source Link
mootinator
  • 1.2k
  • 1
  • 11
  • 17

T-SQL 166 Characters

SELECT PROCEDURE f29 (@d DATE) AS DECLARE @i int SET @i=YEAR(DATEADD(M,-2,@d)) SET @i=@i+(4-@i%4) IF @i % 100 = 0 AND @i % 400 0 SET @i=@i+4 SELECT DATENAME(W, @i) I was already messing with T-SQL date functions, so I figured why not...