choose timestamp that is earlier than

Is there a way to retrieve items from a database that are more than 12 hours old? I'm using a timestamp column to keep track of time, but I only require information based on hours and not year, month, or day.
I've tried the following query, but it's not working as expected (there are no errors, it just retrieves all data from the table).

$sql = "SELECT *FROM Y WHERE X and time > now() - INTERVAL 12 HOUR";

Your input is appreciated, Salman A. Thank you.

Answer №1

Give this a shot:

RETRIEVE * FROM Y WHERE X and TIMESTAMP(time) < (NOW() - INTERVAL 12 HOUR)

Make sure to use < instead of > since you're looking for entries more than 12 hours old.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I am encountering a problem with navigating through the CodeIgniter routing system

Currently, I am tackling a routing issue while working on PHP Codeigniter. Specifically, I am trying to set up dynamic software lists within my application. (:any) = 'Softwareproductslist'; (:any)/(:num) = 'Softwareproductslist'; T ...

Unlocking the Power of Transition: Effortlessly Submitting a Form Post

After the modal finishes fading out, I want my form to be submitted and sent to the email file "refreshform.php". However, currently after the modal fades out, the form does not submit or post anything to the PHP file for sending the email. It simply fades ...

Issue with custom annotations in Symfony 4: @ORMEntity not recognized

While working on the development of my CMS, I encountered a specific issue that I need assistance with. The error message I am facing is as follows: [Semantical Error] The annotation "@Doctrine\ORM\Mapping\Entity" in class ScyLabs\G ...

Tips for invoking or triggering the Ajax change function when there is only a single option available

<select class="custom-select custom-select-sm mb-3" required="true" id="sel_block"> <option value="0">Select Block From Here</option> <?php // Fetch Blocks $sql_block = "SELECT * FROM blocks WHER ...

Setting up your YAML configuration to utilize both PHP and Python with AJAX in a unified project on App Engine

Here is my project idea https://i.stack.imgur.com/oGOam.jpg $.ajax({ url: '../server/python/python_file.py', dataType: 'json', type: 'POST', success:function(data) { //Perform additional AJAX requests using PHP f ...

PHP response working inconsistently when called via ajax

My quest involves passing values to a PHP page that should respond with PHP code for loading. However, the issue arises when the returned PHP code only partially functions. AJAX: $.ajax({ type: 'post', url: 'bundles_drop.php', d ...

the issue with file_get_contents not effectively sending every parameter

I have recently created my own API to communicate between two servers. One server is requesting data using file_get_contents and passing GET Parameters, while the other server responds with JSON. Everything was working smoothly until I made a request with ...

Issue with array merging/inserting feature not functioning as expected

Here are two arrays that I have: First Array: "workingHours": [ { "opening": "09:30", "closing": "13:30", "dayName": "sunday" }, { ...

Pass a jQuery value to a PHP variable

I am looking to send a value when I click a button. For example, when I click on <a id="link1"> Page Home </a>, it should send the value to a custom variable php. Here is an example: <?php $linkredirect = ''; // This will be sent ...

Find and substitute numerous PHP code lines

Hello there, I am a beginner when it comes to using preg_replace and similar functions so please be patient with me. I have several hundred lines that include this specific line: <strong>[*<a title="*" name="*"></a>]</strong><b ...

There was an error in locating the JavaScript file within the Node.js Express Handlebars application

My website is not displaying the .js file, css file, or image from the public folder. Here are the errors showing up in the console: GET http://localhost:8080/assets/images/burger.jpg 404 (Not Found) GET http://localhost:8080/burgers.js net::ERR_ABORTED ...

Eloquent in Laravel 5 makes it easy to retrieve all attributes from two related tables

Hello, I am working with two tables - Users and Posts - that have a one-to-many relationship. My goal is to retrieve all the data in just one query using Eloquent, resulting in: Users Table: id | name Posts Table: id | user_id | title| body The retriev ...

Sending data from Spark to my Angular8 projectLearn how to seamlessly transfer data from your

I am utilizing Spark 2.4.4 and Scala to retrieve data from my MySQL database, and now I am looking to showcase this data in my Angular8 project. Can anyone provide guidance on the process? I have been unable to locate any relevant documentation so far. ...

Upload file to database and move to new location

In order to gain a clearer understanding, I have a question regarding inserting data from a form. Let's say I have the following form: <form action="upload.php" method="post" enctype="multipart/form-data"> Select image to upload: <inp ...

How can AJAX be used for form validation prior to submission?

Currently, I am facing an issue with validation on the client side when making an ajax cross-domain request to my PHP server page. I have a standard HTML form that posts input fields such as name, last name, and message. Here is an example of my form on th ...

Disabling Bootstrap Js, JQuery, and CSS in Yii2

Can anyone suggest an alternative to using bootstrap.css and bootstrap.js? I've attempted the following: 'assetManager' => [ 'bundles' => [ 'yii\bootstrap\BootstrapAsset' => [ & ...

Is there a way to preserve a $this pointer between two classes within separate scripts?

Well, this is a rather interesting scenario: Currently, I am immersed in the world of MVC architecture. There's a User class designated as a library (User.php). Additionally, there's a controller class responsible for managing user input (cont ...

What causes an "Undefined index" error in jQuery when making AJAX requests?

Whenever I make an AJAX request in my main.js file, I encounter the following error message: Undefined index: id in sqlinfo.php on line 13 I am puzzled because I believe that I am populating the request object correctly. What's even more perplexing i ...

Include the clicked link into the text input area using Ajax or Jquery

Hey there, I'm just starting out with jquery and ajax so please be patient with me. Below is a snippet of my script that fetches branch names from the database asynchronously: $(document).ready(function () { $("#pickup").on('keyup' ...

Utilizing Angular to integrate with an external API

I have encountered an issue while trying to connect to the Expedia API. In order to do so, I need an API key and ID. Initially, I utilized JSONP for this connection but ran into a bug causing problems. Additionally, storing my API key in JavaScript poses ...