{"id":8475,"date":"2020-12-08T07:41:00","date_gmt":"2020-12-08T07:41:00","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=8475"},"modified":"2025-08-29T04:40:46","modified_gmt":"2025-08-29T04:40:46","slug":"how-to-round-timestamp-in-mysql","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/how-to-round-timestamp-in-mysql\/","title":{"rendered":"How to Round Timestamp in MySQL"},"content":{"rendered":"\n<p>MySQL is a popular database often used for storing transactional data that contains date, time and timestamp information. Sometimes you may need to round timestamp in MySQL for reporting and data analysis. In this article, we will look at different ways to round timestamp in MySQL. It allows you to transform datetime columns to various formats, as per your requirements.<\/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-round-timestamp-in-mysql\/#Why_Round_Timestamp_in_MySQL\" >Why Round Timestamp 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-round-timestamp-in-mysql\/#How_to_Round_Timestamp_in_MySQL\" >How to Round Timestamp in MySQL<\/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-round-timestamp-in-mysql\/#Using_date_format\" >Using date_format()<\/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-round-timestamp-in-mysql\/#Round_Timestamp_to_Month\" >Round Timestamp to Month<\/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-round-timestamp-in-mysql\/#Round_Timestamp_to_Day\" >Round Timestamp to Day<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-round-timestamp-in-mysql\/#Round_Timestamp_to_Hour\" >Round Timestamp to Hour<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-round-timestamp-in-mysql\/#Round_Timestamp_to_Minute\" >Round Timestamp to Minute<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-round-timestamp-in-mysql\/#Round_Timestamp_to_Seconds\" >Round Timestamp to Seconds<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-round-timestamp-in-mysql\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Why_Round_Timestamp_in_MySQL\"><\/span>Why Round Timestamp in MySQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Timestamp is a data type used to store date and time information at one go, in a single column. They are often used to store transactional information such as sign ups, logins, sales, orders, checkouts, etc. They are generally of the format &#8216;YYYY-MM-DD HH:MM:SS&#8217; (YYYY-year, MM-month, DD-day, HH-hour, MM-minute, SS-second).<\/p>\n\n\n\n<p>Rounding a timestamp means adjusting it to the nearest, specific time period. It may be rounding to nearest year, month, day, hour, minute or even second. Data analysts and web developers need to round timestamp for data analysis and reporting, to aggregate data into regular intervals. This allows you to group continuous data into discrete buckets that can be used for charting and reporting purposes. For example, you can round sales dates to nearest month, to analyze monthly sales numbers.<\/p>\n\n\n\n<p>Also, if you have a large table containing millions of rows of sales data, it can be overwhelming to look at it. Instead, you can simply round timestamp values to nearest month or year to get monthly or annual numbers which are far lesser in number.<\/p>\n\n\n\n<p>Please note, in most cases, rounding of timestamp values are used in SELECT queries without modifying underlying data. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Round_Timestamp_in_MySQL\"><\/span>How to Round Timestamp in MySQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>There are many different ways to round timestamp values. Among them, using date_format() function is the easiest and most versatile.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Using_date_format\"><\/span>Using date_format()<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We will look at how to round timestamp in MySQL using <em>date_format<\/em> function. <em>date_format<\/em> function has the following syntax<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">date_format(value, format_string)<\/pre>\n\n\n\n<p>For date_format function, you need to specify a value that you want to convert and a format string of final value. Depending on the format string, it will change your value to required format. Here is the <a href=\"https:\/\/www.w3schools.com\/sql\/func_mysql_date_format.asp\">list<\/a> of available format specifiers for <em>date_format<\/em> function.<\/p>\n\n\n\n<p>We will also look at how to convert timestamp into hour, minute, date.<\/p>\n\n\n\n<p>Here&#8217;s the SQL query to get present date time.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select now();<br>+---------------------+<br>| now()               |<br>+---------------------+<br>| 2024-07-23 12:39:03 |<br>+---------------------+<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Round_Timestamp_to_Month\"><\/span>Round Timestamp to Month<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>There are two ways to round a timestamp to nearest month. You can either round it down or round it up. Here is the SQL query to round down current timestamp to month.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; SELECT date_format(now(),'%Y-%m') as round_month;<br>+-------------+<br>| round_month |<br>+-------------+<br>| 2024-07     |<br>+-------------+<\/pre>\n\n\n\n<p>Similarly, you can round timestamp column (e.g order_date from sales table) to month<\/p>\n\n\n\n<pre id=\"block-622ab9d8-00d7-4667-aaef-2bd2b2d69cb7\" class=\"wp-block-preformatted\">mysql&gt; SELECT date_format(order_date,'%Y-%m') from sales;<\/pre>\n\n\n\n<p>If you want to round up the current timestamp to nearest month, then you need to add 15 days to the timestamp value using date_add() or other similar function.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; SELECT date_format(date_add(now(), interval 15 day),'%Y-%m') as round_month;<br>+-------------+<br>| round_month |<br>+-------------+<br>| 2024-08     |<br>+-------------+<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Round_Timestamp_to_Day\"><\/span>Round Timestamp to Day<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here too, there are two ways to round a timestamp to a date. You can either round down or round up the value. Here is the SQL query to round down current timestamp to day.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; SELECT date_format(now(),'%Y-%m-%d') as round_date;<br>+------------+<br>| round_date |<br>+------------+<br>| 2024-07-23 |<br>+------------+<\/pre>\n\n\n\n<p>Similarly, you can round timestamp column (e.g order_date from sales table) to day<\/p>\n\n\n\n<pre id=\"block-622ab9d8-00d7-4667-aaef-2bd2b2d69cb7\" class=\"wp-block-preformatted\">mysql&gt; SELECT date_format(order_date,'%Y-%m-%d') from sales;<\/pre>\n\n\n\n<p>If you want to round up the timestamp to nearest date, then you need to add 12 hours to timestamp value using date_add() or other similar functions.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; SELECT date_format(date_add(now(),interval 12 hour),'%Y-%m-%d') round_date;<br>+------------+<br>| round_date |<br>+------------+<br>| 2024-07-24 |<br>+------------+<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Round_Timestamp_to_Hour\"><\/span>Round Timestamp to Hour<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this case, we will round current timestamp value to nearest hour. There are two ways to do this. You can either round down or round up the timestamp value. Here is the SQL query to round down current timestamp to hour.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; SELECT date_format(now(),'%Y-%m-%d %H:00:00') as round_time;<br>+---------------+<br>| round_time    |<br>+---------------+<br>| 2024-07-23 12 |<br>+---------------+<\/pre>\n\n\n\n<p>Similarly, you can round timestamp column (e.g order_date from sales table) to hour<\/p>\n\n\n\n<pre id=\"block-622ab9d8-00d7-4667-aaef-2bd2b2d69cb7\" class=\"wp-block-preformatted\">mysql&gt; SELECT date_format(order_date,'%Y-%m-%d %H') from sales;<\/pre>\n\n\n\n<p>In the above case, the timestamp value will be rounded down to nearest hour value. If you want to round up the timestamp value then add 30 minutes to your timestamp value before calling date_format() on it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; SELECT date_format(date_add(now(),interval 30 minute),'%Y-%m-%d %H:00:00') as round_time;<br>+---------------------+<br>| round_time          |<br>+---------------------+<br>| 2024-07-23 13:00:00 |<br>+---------------------+<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Round_Timestamp_to_Minute\"><\/span>Round Timestamp to Minute<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can round up or round down timestamp to nearest minute. This is required if you are aggregating data on a minute by minute basis. Here is the SQL query to round down current timestamp to minute.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; SELECT date_format(now(),'%Y-%m-%d %H:%i') as round_min;<br>+------------------+<br>| round_min        |<br>+------------------+<br>| 2024-07-23 12:54 |<br>+------------------+<\/pre>\n\n\n\n<p>Similarly, you can round timestamp column (e.g order_date from sales table) to minutes<\/p>\n\n\n\n<pre id=\"block-622ab9d8-00d7-4667-aaef-2bd2b2d69cb7\" class=\"wp-block-preformatted\">mysql&gt; SELECT date_format(order_date,'%Y-%m-%d %H:%i') as round_min from sales;<\/pre>\n\n\n\n<p>If you want to round up timestamp value to nearest minute, add 30 seconds to timestamp value before you call date_format() function.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; SELECT date_format(date_add(now(),interval 30 second),'%Y-%m-%d %H:%i') as round_min;<br>+------------------+<br>| round_min        |<br>+------------------+<br>| 2024-07-23 12:55 |<br>+------------------+<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Round_Timestamp_to_Seconds\"><\/span>Round Timestamp to Seconds<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here is the SQL query to round current timestamp to seconds.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; SELECT date_format(now(),'%Y-%m-%d %H:%i:%s');\n+----------------------------------------+\n| date_format(now(),'%Y-%m-%d %H:%i:%s') |\n+----------------------------------------+\n| 2020-12-08 11:13:10                    |\n+----------------------------------------+<\/pre>\n\n\n\n<p>Similarly, you can round timestamp column (e.g order_date from sales table) to seconds<\/p>\n\n\n\n<pre id=\"block-622ab9d8-00d7-4667-aaef-2bd2b2d69cb7\" class=\"wp-block-preformatted\">mysql&gt; SELECT date_format(order_date,'%Y-%m-%d %H:%i:%s') from sales;<\/pre>\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>As you can see, it is very easy to change datetime and timestamp values to month, day, hour, minute and second. Depending on your requirement, you can use date_format() function, along with appropriate format string. date_format() is a very powerful function that allows you to format your date, time and timestamp values to any format you want. You can also use literal characters in addition to datetime numbers in its format.<\/p>\n\n\n\n<p>We have learnt several common use cases. If you directly call date_format() function on your timestamp value, then it will round it down. If you want to round it up, then you need to add an interval of time to it, before you call date_format() function. In each of the above example, the actual timestamp value in table is not modified. Only the SELECT query result is modified. Also you can use these methods on date, time, datetime as well as timestamp columns.<\/p>\n\n\n\n<p>Need a reporting tool for MySQL? <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-rename-table-in-mysql\/\">How to Rename Table in MySQL<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-run-multiple-mysql-instances-on-same-machine\/\">How to Run Multiple MySQL Instances<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-insert-multiple-rows-in-mysql\/\">How to Insert Multiple Rows in MySQL<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you need to round timestamp to hour, minute, day, seconds, month. Here is how to round timestamp in MySQL<\/p>\n","protected":false},"author":1,"featured_media":8476,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[324],"tags":[467],"class_list":["post-8475","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql","tag-round-timestamp"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Round Timestamp in MySQL - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Sometimes you need to round timestamp to hour, minute, day, seconds, month. Here is how to round timestamp 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-round-timestamp-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 Round Timestamp in MySQL - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Sometimes you need to round timestamp to hour, minute, day, seconds, month. Here is how to round timestamp in MySQL\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/how-to-round-timestamp-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=\"2020-12-08T07:41:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-29T04:40:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/06\/mysql-date-format.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=\"5 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-round-timestamp-in-mysql\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-round-timestamp-in-mysql\\\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How to Round Timestamp in MySQL\",\"datePublished\":\"2020-12-08T07:41:00+00:00\",\"dateModified\":\"2025-08-29T04:40:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-round-timestamp-in-mysql\\\/\"},\"wordCount\":961,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-round-timestamp-in-mysql\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/mysql-date-format.webp?fit=730%2C410&ssl=1\",\"keywords\":[\"round timestamp\"],\"articleSection\":[\"MySQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-round-timestamp-in-mysql\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-round-timestamp-in-mysql\\\/\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-round-timestamp-in-mysql\\\/\",\"name\":\"How to Round Timestamp in MySQL - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-round-timestamp-in-mysql\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-round-timestamp-in-mysql\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/mysql-date-format.webp?fit=730%2C410&ssl=1\",\"datePublished\":\"2020-12-08T07:41:00+00:00\",\"dateModified\":\"2025-08-29T04:40:46+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Sometimes you need to round timestamp to hour, minute, day, seconds, month. Here is how to round timestamp in MySQL\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-round-timestamp-in-mysql\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-round-timestamp-in-mysql\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-round-timestamp-in-mysql\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/mysql-date-format.webp?fit=730%2C410&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/mysql-date-format.webp?fit=730%2C410&ssl=1\",\"width\":730,\"height\":410,\"caption\":\"mysql date format\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-round-timestamp-in-mysql\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Round Timestamp 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 Round Timestamp in MySQL - Ubiq BI","description":"Sometimes you need to round timestamp to hour, minute, day, seconds, month. Here is how to round timestamp 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-round-timestamp-in-mysql\/","og_locale":"en_US","og_type":"article","og_title":"How to Round Timestamp in MySQL - Ubiq BI","og_description":"Sometimes you need to round timestamp to hour, minute, day, seconds, month. Here is how to round timestamp in MySQL","og_url":"https:\/\/ubiq.co\/tech-blog\/how-to-round-timestamp-in-mysql\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2020-12-08T07:41:00+00:00","article_modified_time":"2025-08-29T04:40:46+00:00","og_image":[{"width":730,"height":410,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/06\/mysql-date-format.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":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-round-timestamp-in-mysql\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-round-timestamp-in-mysql\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How to Round Timestamp in MySQL","datePublished":"2020-12-08T07:41:00+00:00","dateModified":"2025-08-29T04:40:46+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-round-timestamp-in-mysql\/"},"wordCount":961,"commentCount":0,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-round-timestamp-in-mysql\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/06\/mysql-date-format.webp?fit=730%2C410&ssl=1","keywords":["round timestamp"],"articleSection":["MySQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ubiq.co\/tech-blog\/how-to-round-timestamp-in-mysql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-round-timestamp-in-mysql\/","url":"https:\/\/ubiq.co\/tech-blog\/how-to-round-timestamp-in-mysql\/","name":"How to Round Timestamp in MySQL - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-round-timestamp-in-mysql\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-round-timestamp-in-mysql\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/06\/mysql-date-format.webp?fit=730%2C410&ssl=1","datePublished":"2020-12-08T07:41:00+00:00","dateModified":"2025-08-29T04:40:46+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Sometimes you need to round timestamp to hour, minute, day, seconds, month. Here is how to round timestamp in MySQL","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-round-timestamp-in-mysql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/how-to-round-timestamp-in-mysql\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-round-timestamp-in-mysql\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/06\/mysql-date-format.webp?fit=730%2C410&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/06\/mysql-date-format.webp?fit=730%2C410&ssl=1","width":730,"height":410,"caption":"mysql date format"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-round-timestamp-in-mysql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How to Round Timestamp 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\/2025\/06\/mysql-date-format.webp?fit=730%2C410&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-2cH","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8475","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=8475"}],"version-history":[{"count":2,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8475\/revisions"}],"predecessor-version":[{"id":9344,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8475\/revisions\/9344"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/8476"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=8475"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=8475"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=8475"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}