开发者

MySQL CURDATE() - yesteday is last day of the month

开发者 https://www.devze.com 2022-12-25 04:41 出处:网络
I have开发者_Go百科 some problem whith such mysql_query INSERT INTO table VALUES (\'\', CURDATE()-1)

I have开发者_Go百科 some problem whith such mysql_query

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

why if yesteday is last day of the month

the CURDATE()-1 result is like 2010-04-00

why not 2010-03-31


When you mix date and number, date is treated as number.

Try:

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


What about the DATE_ADD function?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号