First day of the next month

前端 未结 7 2152
自闭症患者
自闭症患者 2021-02-07 00:37

I\'m trying get the results where it only displays OrderDates before the LAST day of the CURRENT month. I\'m guessing it would be like this...

SELECT OrderDate
F         


        
7条回答
  •  盖世英雄少女心
    2021-02-07 00:38

    First day of next month:

    sql-server 2012+

    DATEADD(d, 1, EOMONTH(current_timestamp))
    

    sql-server 2008 and older:

    DATEADD(m, DATEDIFF(m, -1, current_timestamp), 0)
    

提交回复
热议问题