Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

the use of SUBDATE

Status
Not open for further replies.

steve105

Programmer
Nov 3, 2008
1
GB
Can anyone please advise on the use of SUBDATE as I am clearly missing something.

I have a table (see below) and I want to know what deliveries have been made in August. Deliveries are considered delivered when a delivery note number is added to the deliveryNoteNumber column. I have included what I think the code should be and the RESULT I am expecting.
At the bottom is the error I get when I run the query in phpMyAdmin. I've tried all sorts of combinations with the same error. Thanks in antisipation. Steve

TABLE delivery

deliveryId deliveryNoteNumber deliveryDate
----------+------------------+------------+
1 3001 2008-07-07
2 3005 2008-08-08
3 3002 2008-09-09
4 0 2008-08-10

SELECT * FROM delivery WHERE deliveryNoteNumber > '0' AND deliveryDate SUBDATE('2008-08-31', INTERVAL 1 MONTH)

RESULT

deliveryId deliveryNoteNumber deliveryDate
----------+------------------+------------+
2 3005 2008-08-08

ERROR
#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 'SUBDATE( '2008-08-31' , INTERVAL 1 MONTH )
LIMIT 0, 30' at line 1
 
You probably want "... AND deliveryDate > SUBDATE('2008-08-31', INTERVAL 1 MONTH)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top