Mysql dateadd query problem
-
All, I have been toying with this query for some time now to no avail. I need to run a retention report on sales that canceled within 30, 60, 90 days of the original sale date. My query is below. Could someone please help me in the right direction as to why it doesn't work? The error I get is below the query
SELECT count(*) FROM db.orders where date_entered between "2007-08-01" and "2007-08-31" and cancel_date <= date_add('day', 30, date_entered)
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 '30, date_entered)' at line 2 Thank you very much! -
All, I have been toying with this query for some time now to no avail. I need to run a retention report on sales that canceled within 30, 60, 90 days of the original sale date. My query is below. Could someone please help me in the right direction as to why it doesn't work? The error I get is below the query
SELECT count(*) FROM db.orders where date_entered between "2007-08-01" and "2007-08-31" and cancel_date <= date_add('day', 30, date_entered)
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 '30, date_entered)' at line 2 Thank you very much!Reference for DATE_ADD in MySQL 6.0[^]. I think the correct syntax would be
DATE_ADD(date_entered, INTERVAL 30 DAY)
. MySQL is not SQL Server and they do not necessarily use the same syntax for features that both implement. There is a common but very limited standard SQL syntax; many databases support most of SQL-92, but usually not all of it.DoEvents: Generating unexpected recursion since 1991
-
Reference for DATE_ADD in MySQL 6.0[^]. I think the correct syntax would be
DATE_ADD(date_entered, INTERVAL 30 DAY)
. MySQL is not SQL Server and they do not necessarily use the same syntax for features that both implement. There is a common but very limited standard SQL syntax; many databases support most of SQL-92, but usually not all of it.DoEvents: Generating unexpected recursion since 1991
Thank you so much! That finally got it working. I knew there was a difference in mysql, but I just couldn't figure it out. Usually its the simple things that fix these problems. Thanks again mate!