?
Solved

MySQL Date Addition

Posted on 2006-11-19
6
Medium Priority
?
384 Views
Last Modified: 2008-01-09
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
Comment
Question by:basiclife
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 17975243
DELETE FROM reservation WHERE DATE_ADD(reservedtime , INTERVAL 2 HOUR ) < NOW()
0
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 17975245
more efficient:

DELETE FROM reservation WHERE reservedtime < DATE_SUB( NOW(), INTERVAL 2 HOUR )
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17975246
0
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
LVL 5

Author Comment

by:basiclife
ID: 17975277
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
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17975282
>Thanks both.
Glad I could help... looks you didn't realize i posted all 3 comments :-)
0
 
LVL 5

Author Comment

by:basiclife
ID: 17975289
lol. Sorry. long LONG day. I saw you were 1st/3rd.... for some reason didn't see you were 2nd too
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question