MySQL DATEDIFF() Function The DATEDIFF() function returns the number of days between two date values.
Use the DATEDIFF() function to retrieve the number of days between two dates in a MySQL database. This function takes two arguments: The end date. (In our example, it's the expiration_date column.)
To count the difference between dates in MySQL, use the DATEDIFF(enddate, startdate) function. The difference between startdate and enddate is expressed in days. In this case, the enddate is arrival and the startdate is departure .
SELECT DAY(LAST_DAY(yourdate))
You can combine LAST_DAY with string function
SELECT RIGHT( LAST_DAY( '2003-02-03' ) , 2 )
Try this:
SELECT DAYOFMONTH(LAST_DAY(your_date)) FROM your_table
An alternative to string-chopping is to use:
SELECT DAY(LAST_DAY('2010-02-1'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With