MySql query syntax error DATE_SUB
NickName:user1456574 Ask DateTime:2012-06-14T23:02:32

MySql query syntax error DATE_SUB

what's wront with this query?

SELECT * 
FROM containmentTracker 
WHERE reviewDate < NOW() 
  AND reviewDate > DATE_SUB(NOW(), INTERVAL 10 YEARS)

I've tried in several way but every time I use DATE_SUB I get

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 'YEARS)' at line 1

or similar errors.

What I'm doing wrong?

Thank you

Copyright Notice:Content Author:「user1456574」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/11035953/mysql-query-syntax-error-date-sub

More about “MySql query syntax error DATE_SUB” related questions

MySql query syntax error DATE_SUB

what's wront with this query? SELECT * FROM containmentTracker WHERE reviewDate &lt; NOW() AND reviewDate &gt; DATE_SUB(NOW(), INTERVAL 10 YEARS) I've tried in several way but every time I use

Show Detail

DATE_SUB syntax error

I am trying to create a cron job to delete records that are more than an hour old and the field 'activated' = 0 but I keep getting a message to check my syntax. $sql = "DELETE * FROM user WHERE

Show Detail

Simple date_sub() mySQL Query failing to execute

Here's the Query I'm attempting to execute just to no avail SELECT p.*, c.* FROM `players` AS `p` INNER JOIN `price_checks` AS `c` ON `c`.`resourceId` = `p`.`Player_Resource`

Show Detail

MySQL - Search Query between DATE_SUB() AND DATE_SUB() Error

I am trying to do a search query (using pdo php and mysql) between a date range which is between (date-7days) and (date-1day) using DATE_SUB() on both so for example: end_date is 2013-03-26 search

Show Detail

MySQL 1064 syntax error cant find error

can someone please help me with this sql query. it gives me a 1064 error suggesting I have a syntax error in my query. I've looked for the error over 2 hours now and getting frustrated now. SELECT...

Show Detail

DATE_SUB named query MYSQL

Have a named query written like this select u from User u where u.creationdate &lt; DATE_SUB(CURDATE(),INTERVAL :upperDate DAY) and status=:status and reminder_counter =:counter But I get a Syntax

Show Detail

Mysql DATE_SUB(NOW(), INTERVAL 365 DAY) MYSQL ERROR

SELECT DATE_FORMAT(created_date,'%W') as day, DATE_FORMAT(created_date,'%d') as dat, DATE_FORMAT(created_date,'%M') as mon, created_date as dated, SUM(price) AS amount FROM `order_invoice` BETWEEN

Show Detail

Error in MySQL to HiveQL Conversion including DATE_SUB and INTERVAL

I am trying to convert the query written in MySQL to HiveQL The part of query giving me error is : WHERE 1 = 1 AND table1.incoming_date &gt;= DATE_SUB(DATE_SUB(CURDATE(),INTERVAL DAY(CURDATE()) -...

Show Detail

MYSQL trigger Query syntax error

MYSQL: DELIMITER $$ CREATE TRIGGER `Activation_code` BEFORE UPDATE ON `user_users` FOR EACH ROW BEGIN (CASE WHEN (OLD.activation_code_time &lt; UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 15

Show Detail

SQL Syntax error in PDO Query

I am running this query in PHP PDO $stmt = $pdo_conn-&gt;prepare("SELECT * from integra_status where type = :type and maintenance_fromdate &lt;= DATE_ADD(NOW(), INTERVAL 7 DAY) and maintenance_tod...

Show Detail