Home >Database >Mysql Tutorial >How to Query MySQL for Records Created on or After Today?
Retrieving MySQL Records Created Today or Later
This guide demonstrates how to fetch data from a MySQL table where the creation timestamp is on or after the current date.
Use this SQL query:
<code class="language-sql">SELECT * FROM users WHERE created >= CURDATE();</code>
CURDATE()
returns today's date. The >=
operator ensures that only records with a created
datetime greater than or equal to today are included.
Important Consideration: You might need to retrieve records before today's date. If so, use this query instead:
<code class="language-sql">SELECT * FROM users WHERE created < CURDATE();</code>
MySQL offers flexible datetime comparisons. For instance:
<code class="language-sql">SELECT NOW();</code>
This query returns the current date and time. Remember to adapt the created
column name to match your specific table structure.
The above is the detailed content of How to Query MySQL for Records Created on or After Today?. For more information, please follow other related articles on the PHP Chinese website!