Jump to content

MySQL last day of month


MoFish

Recommended Posts

Hi,

Is it possible to get the last date of a month in mysql on a start date variable?

 

Example...

WHERE date >= '$date' and date <= GETLASTDAY('$date'):

I'm aware this wont work - but may help understand what i'm trying to achieve.

I currently pass in a variable called $date which has a value of "2013-11-01" . I'm hoping to execute a mysql query where it would figure out the last possible date in that month based on the $date variable e.g '2013-11-30'.

 

In theory i want to execute something like the below - but it automagically figure out the second value

WHERE date >= '2013-11-01' and date <= '2013-11-30':

Is there an easy way to do this?

 

Thanks,

 

MoFish

Link to comment
https://forums.phpfreaks.com/topic/284359-mysql-last-day-of-month/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.