Wednesday 31 August, 2011

How to Get 21st date of the any month in sql server


SELECT DATEADD(d,
case when(datepart(dd,DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0)))=31) then -11
when(datepart(dd,DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0)))=30) then -10
when(datepart(dd,DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0)))=29) then -9
else -8 end,
DATEADD(mm, DATEDIFF(m,0,GETDATE()),0))


Tag: 21st date of any month in sql, 21st date of any month in sql server, last date of any month in sql server, last date of month in sql, last date of month in sql server

No comments:

Post a Comment

Parsing JSON w/ @ symbol in it

To read the json response like bellow @ concatenated with attribute                             '{ "@id": 1001, "@name&q...