jueves, noviembre 05, 2015

Calcular en Mysql el primer y último día del mes



SELECT DATE_FORMAT(now(),'%Y-%m-01') AS first_day;

SELECT date_add(date_add(LAST_DAY(now()),interval 1 DAY),interval -1 MONTH) AS first_day;


SELECT LAST_DAY(now()) AS last_day;



Calcular en Mysql el primer y último día del mes anterior:
SELECT date_add(date_add(LAST_DAY(now()),interval 1 DAY),interval -2 MONTH) AS first_day;

SELECT LAST_DAY(date_add(last_day(now()),interval -1 MONTH)) AS last_day;
Publicar un comentario