How do I know how many days the current month has?

4

How to know how many days the current MySQL month has, example: setembro = 30dias

Reason:

I have a goal: exemplo: 1.000,000

I need to get the value of the goal and divide by the number of days it has in the current month to return the value of the daily goal.

    
asked by anonymous 21.09.2016 / 15:46

3 answers

6
SELECT LAST_DAY(data)

>     
21.09.2016 / 15:51
4

In this context I would use two functions, the CURDATE() to know the date of the day and the LAST_DAT() that returns the last day of the month from a date.

SELECT LAST_DAY( CURDATE() ) as DIAS_MES

CURDATE () - Documentation

LAST_DAY () - Documentation

    
21.09.2016 / 16:57
1

Just complementing the information, as the friend wants the number of days.

SELECT DAY(LAST_DAY( data_field )) as DIAS_MES;
    
08.11.2017 / 18:53