• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 420
  • Last Modified:

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?
0
basiclife
Asked:
basiclife
  • 4
  • 2
2 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
DELETE FROM reservation WHERE DATE_ADD(reservedtime , INTERVAL 2 HOUR ) < NOW()
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
more efficient:

DELETE FROM reservation WHERE reservedtime < DATE_SUB( NOW(), INTERVAL 2 HOUR )
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now