Number of days left in current month

后端 未结 6 907
梦谈多话
梦谈多话 2021-01-15 03:44

Number of days left in a given month How do I find the number of days left in the current month? Example if current month is November and todays date is 16/11/2016 The Numb

6条回答
  •  深忆病人
    2021-01-15 04:39

    --For SQL 2012 And Above Version Use Below Query to Get Count Of Days Left In A Month
    
    DECLARE @date DATE
    SET @date=GETDATE()
    SELECT DATEDIFF(DAY, @date,EOMONTH(@date)) 
    
    -- And for Sql Server 2008 Use Below Query to Get Count of Days Left for the Month
        DECLARE @date Date 
             SET @date=GETDATE()
             SELECT DATEDIFF(DAY, @date, DATEADD(MONTH, 1, @date)) - DATENAME(DAY,GETDATE())
         AS DaysLeft
    

提交回复
热议问题