How to Get Today’s Date




You want to use today’s date in your SQL query, but don’t want to type it in each day.


You can use GETDATE() to return the current date and time.  But to remove the time part case the result as a DATE.

Assuming the current date is 2022-02-27, then




Here you can see the SQL used to get today’s date and the current time.

Get Today's Date example and results


Keep in mind that GETDATE() returns the type datetime.  SQL will implicitly convert the type for you, but if you don’t need to worry about hours, minutes, and seconds, it’s best to just use CAST as we did to get today’s date.

You can CAST GETDATE() to a date.  This makes it easier to read, and also apparent, you’re working with a calendar date, not a specific point in time.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

More from the blog

MySQL PostgreSQL SQLite SQL Server