Friday 2 February 2018

Days in month in Sql Server Tricks

  • Days in month in sql server
  • Last day of any moth in sql server
  • Last day of month calculation in sql server tricks

DECLARE @date DATETIME
SET @date = '02/01/2018'
SELECT DAY(EOMONTH(@date)) AS DaysInMonth
--Output:28
 
DECLARE @date DATETIME
SET @date = '02/01/2018'
SELECT   DATEDIFF(d, @date, DATEADD(m, 1, @date))  DaysInMonth
--Output:28