How to Get the Current Date Without Time in SQL

Do you need to get the current date without the time in SQL? It's a common task, and thankfully there's an easy way to do it. In this post, we'll look at how to get the current date without time in SQL using the CURRENT_DATE function. 🤓

The Solution

The solution is to use the CURRENT_DATE function. This function takes no arguments and returns the current date without the time. For example, if you wanted to get the current date, you would use the following query:

SELECT CURRENT_DATE;

Examples

Let's look at a few examples of how this function can be used. Suppose you have a table called users with the following data:

users
nameagedate_joined
John252020-01-01
Jane302020-02-01
John252020-03-01
Bob202020-04-01

If you wanted to get the current date, you would use the following query:

SELECT CURRENT_DATE;

This query would return the result 2020-05-01, which is the current date without the time.

Additional Info

The CURRENT_DATE function is supported by most major databases, including MySQL, PostgreSQL, and SQL Server. However, the syntax may vary slightly depending on the database you are using. For more information, check out the documentation for your particular database. 🤓

Want to build your own LLM Apps with AirOps👇👇