MySQL CURDATE () - last day of the month

I have some problems with such mysql_query

INSERT INTO table VALUES ('', CURDATE()-1)

why if yestay is the last day of the month

The result CURDATE()-1is similar to2010-04-00

why not 2010-03-31

+3
source share
2 answers

When you mix date and number, the date is considered a number.

Try:

INSERT INTO table VALUES ('', date_sub(CURDATE(), interval 1 day));
+10
source

What about the DATE_ADD function ?

+1
source

Source: https://habr.com/ru/post/1739569/


All Articles