I want to use PHP and MySQL to INSERT the the day of Yesterday. So my idea was:
INTO chartValues SET timestamp='1353369600', `datetime`=DATEADD(d,-1,GETDATE())
But its not working:
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
Thanks in advance
DATEADD
and GETDATE()
are T-SQL functions used in SQL Server.
You want to use DATE_ADD()
or DATE_SUB()
with NOW()
INSERT INTO chartValues SET timestamp='1353369600', `datetime`= DATE_SUB(NOW(), INTERVAL 1 DAY)
DATE_SUB(date, INTERVAL expr unit)