{"id":8380,"date":"2021-02-02T04:32:00","date_gmt":"2021-02-02T04:32:00","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=8380"},"modified":"2025-09-01T05:38:57","modified_gmt":"2025-09-01T05:38:57","slug":"how-to-get-last-1-hour-data-in-mysql","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/","title":{"rendered":"How To Get Last 1 Hour Data in MySQL"},"content":{"rendered":"\n<p>Database programmers and data analysts often need to fetch data for last 1 hour for reporting and analysis. MySQL provides tons of useful functions and statements for time series reporting. It is good to learn how to get last 1 hour records, or retrieve last 1 hour rows for reporting and analysis. There are several ways to do this. In this article, we will look at how to get last 1 hour data in MySQL.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/#How_To_Get_Last_1_Hour_Data_in_MySQL\" >How To Get Last 1 Hour Data in MySQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/#1_Using_Now_function\" >1. Using Now() function<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/#2_Using_Date_sub_function\" >2. Using Date_sub() function<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/#3_How_to_Get_Current_Hour_Data_in_MySQL\" >3. How to Get Current Hour Data in MySQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_To_Get_Last_1_Hour_Data_in_MySQL\"><\/span>How To Get Last 1 Hour Data in MySQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>It is very easy to select last 1 hour data in MySQL using INTERVAL clause. Let us say you have the following table <em>sales(id, order_date, amount)<\/em>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; create table sales(\n         id int, \n         order_date datetime, \n         amount int);\n\nmysql&gt; insert into sales(id, order_date, amount)\n      values(1, '2021-02-02 08:15:00',250),\n      (2, '2021-02-02 08:30:00',150),\n      (3, '2021-02-02 08:55:00',200),\n      (4, '2021-02-02 09:15:00',125),\n      (5, '2021-02-02 09:30:00',200),\n      (6, '2021-02-02 09:45:00',250);\n\n mysql&gt; select * from sales;\n +------+---------------------+--------+\n | id   | order_date          | amount |\n +------+---------------------+--------+\n |    1 | 2021-02-02 08:15:00 |    250 |\n |    2 | 2021-02-02 08:30:00 |    150 |\n |    3 | 2021-02-02 08:55:00 |    200 |\n |    4 | 2021-02-02 09:15:00 |    125 |\n |    5 | 2021-02-02 09:30:00 |    200 |\n |    6 | 2021-02-02 09:45:00 |    250 |\n +------+---------------------+--------+<\/pre>\n\n\n\n<p>We will learn 3 different ways to get data for last 1 hour in MySQL.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Using_Now_function\"><\/span>1. Using Now() function<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Now() is a built-in MySQL function that returns the present datetime value, when invoked. You can use this to get data for past 1 hour. Here is the SQL to show latest time using <em><a href=\"https:\/\/www.w3resource.com\/mysql\/date-and-time-functions\/mysql-now-function.php\" target=\"_blank\" rel=\"noreferrer noopener\">now()<\/a><\/em> function.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select now();\n +---------------------+\n | now()               |\n +---------------------+\n | 2021-02-02 09:48:27 |\n +---------------------+<\/pre>\n\n\n\n<p>Here is the SQL to get last 1 hour data in MySQL.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select * \n       from sales \n       where order_date &gt; now() - interval 1 hour;\n +------+---------------------+--------+\n | id   | order_date          | amount |\n +------+---------------------+--------+\n |    3 | 2021-02-02 08:55:00 |    200 |\n |    4 | 2021-02-02 09:15:00 |    125 |\n |    5 | 2021-02-02 09:30:00 |    200 |\n |    6 | 2021-02-02 09:45:00 |    250 |\n +------+---------------------+--------+<\/pre>\n\n\n\n<p>In the above query, we select only those rows whose <em>order_date<\/em> falls within past 1 hour interval. We use INTERVAL clause to easily substract 1 hour interval from present time obtained using <em>now()<\/em> function. INTERVAL clause allows you to add or subtract a certain interval of time from a date time value in MySQL. This value can be a literal string or a datetime column.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Using_Date_sub_function\"><\/span>2. Using Date_sub() function<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Alternatively, you can also use date_sub() function to retrieve data for past 1 hour in MySQL. It basically subtracts a user specific interval of time from a date literal string or column and returns the result. In the following query, we select rows where order_date value is greater than or equal to the value returned by date_sub() function after subtracting 1 hour from now() function&#8217;s result, that is, the current datetime.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select * <br>       from  sales<br>       where order_date &gt;= DATE_SUB(NOW(),INTERVAL 1 HOUR); <br> +------+---------------------+--------+<br> | id   | order_date          | amount |<br> +------+---------------------+--------+<br> |    3 | 2021-02-02 08:55:00 |    200 |<br> |    4 | 2021-02-02 09:15:00 |    125 |<br> |    5 | 2021-02-02 09:30:00 |    200 |<br> |    6 | 2021-02-02 09:45:00 |    250 |<br> +------+---------------------+--------+<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_How_to_Get_Current_Hour_Data_in_MySQL\"><\/span>3. How to Get Current Hour Data in MySQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Sometimes you may need to get records of current hour in MySQL. This is slightly different from getting past 1 hour&#8217;s data but can be seen as its variation. Here we need the data pertaining to the present hour only. Here is the SQL query to retrieve current hour data.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select * from sales \n       where date(order_date)=date(now()) \n        and hour(order_date)=hour(now());\n +------+---------------------+--------+\n | id   | order_date          | amount |\n +------+---------------------+--------+\n |    4 | 2021-02-02 09:15:00 |    250 |\n |    5 | 2021-02-02 09:30:00 |    250 |\n |    6 | 2021-02-02 09:45:00 |    250 |\n +------+---------------------+--------+<\/pre>\n\n\n\n<p>In the above SQL query, we select only those records whose <em>order_date<\/em> column&#8217;s DATE and HOUR values are same as those of present datetime obtained using now() function. We use DATE and HOUR functions to get date and hour values from datetime values. You can also use date_format() function to round datetime values to nearest hour.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this article, we have learnt several simple ways to get data pertaining to past 1 hour in MySQL. The key is to select rows where your datetime column&#8217;s value is greater than or equal to present time minus 1 hour. You can do this subtraction using plain mathematical operator &#8216;-&#8216; or using date_sub() function. In both cases, you need to use INTERVAL clause to get a time interval of 1 hour. Being able to get data for past 1 hour is very useful especially in reporting environments where your team needs to constantly keep track of latest happenings on your website.<\/p>\n\n\n\n<p>Need a reporting tool for MySQL?&nbsp;<a href=\"http:\/\/ubiq.co\/\">Ubiq<\/a>&nbsp;makes it easy to visualize data in minutes, and monitor in real-time dashboards.&nbsp;<a href=\"http:\/\/ubiq.co\/accounts\/register\">Try it<\/a>&nbsp;Today!<\/p>\n\n\n\n<p>Also read:<br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-show-rows-not-present-in-another-table-in-mysql\/\">How to Show Rows Not Present in Another Table in MySQL<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-get-current-week-data-in-mysql\/\">How to Get Current Week Data in MySQL<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/select-top-10-records-for-each-category-in-mysql\/\">Select Top 10 Records in Each Category in MySQL<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is useful to fetch last 1 hour rows or retrieve last 1 hour records. Here is how to get last 1 hour data in MySQL.<\/p>\n","protected":false},"author":1,"featured_media":8382,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[324],"tags":[438],"class_list":["post-8380","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql","tag-get-last-1-hour-data"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How To Get Last 1 Hour Data in MySQL - Ubiq BI<\/title>\n<meta name=\"description\" content=\"It is useful to fetch last 1 hour rows or retrieve last 1 hour records. Here is how to get last 1 hour data in MySQL.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Get Last 1 Hour Data in MySQL - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"It is useful to fetch last 1 hour rows or retrieve last 1 hour records. Here is how to get last 1 hour data in MySQL.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/\" \/>\n<meta property=\"og:site_name\" content=\"Ubiq BI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ubiqbi\" \/>\n<meta property=\"article:published_time\" content=\"2021-02-02T04:32:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-01T05:38:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/02\/get-last-1-hour-data.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"730\" \/>\n\t<meta property=\"og:image:height\" content=\"410\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Sreeram Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:site\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sreeram Sreenivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-get-last-1-hour-data-in-mysql\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-get-last-1-hour-data-in-mysql\\\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How To Get Last 1 Hour Data in MySQL\",\"datePublished\":\"2021-02-02T04:32:00+00:00\",\"dateModified\":\"2025-09-01T05:38:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-get-last-1-hour-data-in-mysql\\\/\"},\"wordCount\":587,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-get-last-1-hour-data-in-mysql\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/get-last-1-hour-data.webp?fit=730%2C410&ssl=1\",\"keywords\":[\"get last 1 hour data\"],\"articleSection\":[\"MySQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-get-last-1-hour-data-in-mysql\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-get-last-1-hour-data-in-mysql\\\/\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-get-last-1-hour-data-in-mysql\\\/\",\"name\":\"How To Get Last 1 Hour Data in MySQL - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-get-last-1-hour-data-in-mysql\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-get-last-1-hour-data-in-mysql\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/get-last-1-hour-data.webp?fit=730%2C410&ssl=1\",\"datePublished\":\"2021-02-02T04:32:00+00:00\",\"dateModified\":\"2025-09-01T05:38:57+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"It is useful to fetch last 1 hour rows or retrieve last 1 hour records. Here is how to get last 1 hour data in MySQL.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-get-last-1-hour-data-in-mysql\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-get-last-1-hour-data-in-mysql\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-get-last-1-hour-data-in-mysql\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/get-last-1-hour-data.webp?fit=730%2C410&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/get-last-1-hour-data.webp?fit=730%2C410&ssl=1\",\"width\":730,\"height\":410,\"caption\":\"get last 1 hour data\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-get-last-1-hour-data-in-mysql\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Get Last 1 Hour Data in MySQL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\",\"name\":\"Ubiq BI\",\"description\":\"Build dashboards &amp; reports in minutes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\",\"name\":\"Sreeram Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"caption\":\"Sreeram Sreenivasan\"},\"description\":\"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/sreeram-sreenivasan\\\/\"],\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/author\\\/wordpress\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Get Last 1 Hour Data in MySQL - Ubiq BI","description":"It is useful to fetch last 1 hour rows or retrieve last 1 hour records. Here is how to get last 1 hour data in MySQL.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/","og_locale":"en_US","og_type":"article","og_title":"How To Get Last 1 Hour Data in MySQL - Ubiq BI","og_description":"It is useful to fetch last 1 hour rows or retrieve last 1 hour records. Here is how to get last 1 hour data in MySQL.","og_url":"https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2021-02-02T04:32:00+00:00","article_modified_time":"2025-09-01T05:38:57+00:00","og_image":[{"width":730,"height":410,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/02\/get-last-1-hour-data.webp","type":"image\/webp"}],"author":"Sreeram Sreenivasan","twitter_card":"summary_large_image","twitter_creator":"@UbiqBI","twitter_site":"@UbiqBI","twitter_misc":{"Written by":"Sreeram Sreenivasan","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How To Get Last 1 Hour Data in MySQL","datePublished":"2021-02-02T04:32:00+00:00","dateModified":"2025-09-01T05:38:57+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/"},"wordCount":587,"commentCount":0,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/02\/get-last-1-hour-data.webp?fit=730%2C410&ssl=1","keywords":["get last 1 hour data"],"articleSection":["MySQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/","url":"https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/","name":"How To Get Last 1 Hour Data in MySQL - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/02\/get-last-1-hour-data.webp?fit=730%2C410&ssl=1","datePublished":"2021-02-02T04:32:00+00:00","dateModified":"2025-09-01T05:38:57+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"It is useful to fetch last 1 hour rows or retrieve last 1 hour records. Here is how to get last 1 hour data in MySQL.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/02\/get-last-1-hour-data.webp?fit=730%2C410&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/02\/get-last-1-hour-data.webp?fit=730%2C410&ssl=1","width":730,"height":410,"caption":"get last 1 hour data"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-get-last-1-hour-data-in-mysql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How To Get Last 1 Hour Data in MySQL"}]},{"@type":"WebSite","@id":"https:\/\/ubiq.co\/tech-blog\/#website","url":"https:\/\/ubiq.co\/tech-blog\/","name":"Ubiq BI","description":"Build dashboards &amp; reports in minutes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc","name":"Sreeram Sreenivasan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","caption":"Sreeram Sreenivasan"},"description":"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.","sameAs":["https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/"],"url":"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2021\/02\/get-last-1-hour-data.webp?fit=730%2C410&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-2ba","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8380","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/comments?post=8380"}],"version-history":[{"count":3,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8380\/revisions"}],"predecessor-version":[{"id":9402,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8380\/revisions\/9402"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/8382"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=8380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=8380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=8380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}