Check if date is equal to last day of month

Morten

Registered User.
Local time
Today, 08:45
Joined
Sep 16, 2009
Messages
53
I have two date columns in my table called "End date" and "Closing date".
An example could be 14-06-2015 and 13-04-2017.

I need to make a query which is checking if the two dates are equal to the last day of their respective month. I don't have two columns in the table with the last day of month, so I first need to find out what the last day in the month is.

How can I make this query?

Best regards
Morten
 
try

day(dateadd("d",1,mydate))=1

this adds 1 day to the day you want to check - if it =1 then that is the first of the month, ergo the date you want to check is the last day of the month
 
There is one funky way to get the last date of a Month, this will make use of the DateSerial function. Something along the lines of,
Code:
SELECT 
    theListOfAllFieldsYouWant
FROM
    yourTableName
WHERE
    EndDate = DateSerial(Year(EndDate), Month(EndDate) + 1,0)
    OR
    ClosingDate = DateSerial(Year(ClosingDate), Month(ClosingDate) + 1,0)
 

Users who are viewing this thread

Back
Top Bottom