Mysql
 sql >> Database >  >> RDS >> Mysql

Ottieni la prima e l'ultima data del prossimo mese in MySQL

Usa:

SELECT

DATE_SUB(
    LAST_DAY(
        DATE_ADD(NOW(), INTERVAL 1 MONTH)
    ), 
    INTERVAL DAY(
        LAST_DAY(
            DATE_ADD(NOW(), INTERVAL 1 MONTH)
        )
    )-1 DAY
) AS firstOfNextMonth,

LAST_DAY(
    DATE_ADD(NOW(), INTERVAL 1 MONTH)
)AS lastOfNextMonth