Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to find out number of days in month in mysql

Tags:

date

sql

mysql

People also ask

How do I count days in MySQL?

MySQL DATEDIFF() Function The DATEDIFF() function returns the number of days between two date values.

How do I count days in SQL query?

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.)

How can I get the number of days between two dates in MySQL?

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'));