Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8946527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:32:36+00:00 2026-06-15T12:32:36+00:00

I have Rails application which using MYSQL as database. For some condition, I have

  • 0

I have Rails application which using MYSQL as database. For some condition, I have to delete all the records from table which was stored exactly 2 hours before the current time.

My query is :

DELETE FROM TABLE_NAME WHERE (NOW() - created_at) > 7200;

Here create_at is datetime column type. Storing the value in the format “2012-12-04 06:39:44”

My problem is, the above query fetch the records even though the record created time is just 40 to 50 minutes and got deleted. The only problem is the record got delete after it reach 40 to 50 minx from it create time.

Can any one please correct my query. I want the MySQL solution. Please help me

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:32:37+00:00Added an answer on June 15, 2026 at 12:32 pm

    You probably need this if you want to delete records created exactly 2 hours ago:

    DELETE FROM TABLE_NAME WHERE created_at = NOW() - INTERVAL 2 HOUR
    

    or this, that will delete all records created more than 2 hours ago:

    DELETE FROM TABLE_NAME WHERE created_at < NOW() - INTERVAL 2 HOUR
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Ruby on Rails application which is using MySQL database. For now I'm
I have a RAILS 3.x application developed locally using MySQL which has data which
I have created a blog application using Ruby on Rails which includes the ability
In my rails application, I have a controller called demo which is stored at
I have a Rails application with several models-views-controllers which have some similar characteristics, for
I have a rails app that requires multi-table inheritance for which I am using
I have a ruby on rails 3.0 application which will need a database containing
I have a relationship table in a rails application called edit_privileges , in which
I have a rails application in which I implemented some feature. Now I want
I have a Rails 3 application of which some controllers are normal rails controllers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.