How to select last hour without timestamp in MySQL
I would like to select all records from the last hour. Problem is, that I don't have an timestamp. I save the time in one row, and in another the date.
date time 2015-11-27 10:55:04 2015-11-27 11:16:38 2015-11-27 11:57:29 2015-11-27 13:04:47 2015-11-27 14:29:00 2015-11-27 14:36:41 2015-11-27 14:52:46 2015-11-27 15:06:20 2015-11-27 15:30:24 2015-11-27 15:47:15
Is it possible to convert this to a timestamp in order to make the selection i wish according to this method: select rows from last 2 hours
I think I could solve the problem by myself. Thanks for your hints.
SELECT * FROM recs WHERE TIMESTAMP(`datefield`,`timefield`) BETWEEN DATE_SUB(NOW(), INTERVAL 1 HOUR) AND NOW();
- A Linux, Apache, MySQL, PHP (LAMP) stack is a combination of open source software that is typically installed together to enable a server to host dynamic […]
- MySQL is an the most popular open-source database management system, in most of hosting company its has been bundle by LAMP(Linux, Apache, MySQL, PHP/Python/Perl) stack. Another alternative […]
- MySQL is the world’s most popular open-source database. Despite its powerful features, MySQL is simple to set up and easy to use. Below are some instructions […]