MySQL Date Addition

I'm trying for something like this:

DELETE FROM reservation WHERE reservedtime + INTERVAL '2' HOUR < NOW()

I've seen any number of examples but not a lot seem to work :s

Anyone have the correct syntax please?
LVL 5
basiclifeAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
DELETE FROM reservation WHERE DATE_ADD(reservedtime , INTERVAL 2 HOUR ) < NOW()
0
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
more efficient:

DELETE FROM reservation WHERE reservedtime < DATE_SUB( NOW(), INTERVAL 2 HOUR )
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
basiclifeAuthor Commented:
Thank you. I awas using angelIII's soution before but it wasn't deleting the records intended. I've just realised - The server is in the US, I'm in the Uk. The records were transferred from my machine to the server. The timestamp is about 7 hours out... *sigh*

Even points split coming up. Thanks both.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>Thanks both.
Glad I could help... looks you didn't realize i posted all 3 comments :-)
0
 
basiclifeAuthor Commented:
lol. Sorry. long LONG day. I saw you were 1st/3rd.... for some reason didn't see you were 2nd too
0
All Courses

From novice to tech pro — start learning today.