gpt4 book ai didi

mysql - 插入 SQL DATEADD 昨天

转载 作者:可可西里 更新时间:2023-11-01 07:06:26 26 4
gpt4 key购买 nike

我想使用 PHP 和 MySQL 插入昨天的日期。所以我的想法是:

INTO chartValues SET timestamp='1353369600', `datetime`=DATEADD(d,-1,GETDATE())

但它不起作用:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO chartValues SET timestamp='1353369600', datetime=DATEADD(d,-1,GETDATE())' at line 1

提前致谢

最佳答案

DATEADDGETDATE() 是 SQL Server 中使用的 T-SQL 函数。

您想将 DATE_ADD()DATE_SUB()NOW() 一起使用

INSERT INTO chartValues SET timestamp='1353369600', `datetime`= DATE_SUB(NOW(), INTERVAL 1 DAY)

Reference

DATE_SUB(date, INTERVAL expr unit)

关于mysql - 插入 SQL DATEADD 昨天,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13497420/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com