{"id":659,"date":"2014-08-23T10:57:31","date_gmt":"2014-08-23T10:57:31","guid":{"rendered":"http:\/\/www.nikola-breznjak.com\/blog\/?p=659"},"modified":"2016-04-23T12:29:44","modified_gmt":"2016-04-23T12:29:44","slug":"how-to-compare-todays-date-with-the-one-you-have-in-the-mysql-timestamp-field","status":"publish","type":"post","link":"https:\/\/nikola-breznjak.com\/blog\/quick-tips\/how-to-compare-todays-date-with-the-one-you-have-in-the-mysql-timestamp-field\/","title":{"rendered":"How to compare today&#8217;s date with the one you have in the MySQL timestamp field"},"content":{"rendered":"<p>Say you have a field called <strong>date<\/strong> in your MySQL table and its type is\u00a0<a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/datetime.html\">timestamp<\/a>\u00a0(example: &#8216;2014-08-23 08:37:57&#8217;), and you want to get all the records for today (so, all the records who&#8217;s dates are &#8216;2014-08-23&#8217; neverminding the time). Here&#8217;s how yo do that:<\/p>\n<pre class=\"lang:default decode:true \">SELECT * FROM `the_table` WHERE date(date) = curdate();<\/pre>\n<p>So, we&#8217;re using <a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/date-and-time-functions.html#function_date\">date()<\/a> and <a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/date-and-time-functions.html#function_curdate\">curdate()<\/a> functions here to help us achieve that.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Say you have a field called date in your MySQL table and its type is\u00a0timestamp\u00a0(example: &#8216;2014-08-23 08:37:57&#8217;), and you want to get all the records for today (so,&hellip;<\/p>\n","protected":false},"author":1,"featured_media":660,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-659","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-quick-tips"],"_links":{"self":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/659","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/comments?post=659"}],"version-history":[{"count":1,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/659\/revisions"}],"predecessor-version":[{"id":661,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/659\/revisions\/661"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/media\/660"}],"wp:attachment":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/media?parent=659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/categories?post=659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/tags?post=659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}