Get the last day of the month in SQL

后端 未结 20 2137
借酒劲吻你
借酒劲吻你 2020-11-27 04:49

I need to get the last day of the month given as a date in SQL. If I have the first day of the month, I can do something like this:

DATEADD(DAY, DATEADD(MONT         


        
20条回答
  •  粉色の甜心
    2020-11-27 05:06

    This works for me, using Microsoft SQL Server 2005:

    DATEADD(d,-1,DATEADD(mm, DATEDIFF(m,0,'2009-05-01')+1,0))
    

提交回复
热议问题