Calculate the Last Day of the Month

Posted on Friday, September 16th, 2011 at 8:20 pm in

Here is how to calculate the last day of the current month.

Powerbuilder

date ld_eom

ld_eom = RelativeDate(Date(String(Month(Today()) + 1) + "/1/" + String(Year(Today()))), -1)

SQL Server

SELECT DATEADD(DAY, -1, DATEADD(MONTH, DATEDIFF(MONTH, 0, Getdate()) +1, 0))

I quess SQL Denali has a new function (EOMONTH) to do this too.

SELECT EOMONTH(GETDATE())

Top