Wednesday, July 31, 2013

how to get total no of days in a month using sql server

To get the total no of days in a month in sql

Query

DECLARE @sample datetime
SET @sample=GETDATE()  -- Sample date
select datediff(dd,dateadd(dd, 1-day(@sample),@sample), dateadd(m,1,dateadd(dd, 1-day(@sample),@sample)))

No comments:

Post a Comment