Back to cookbooks list Articles Cookbook

How to Get the Current Date in MySQL

  • CURDATE()

Table of Contents

Problem

You’d like to get the current date in MySQL.

Solution

Use the CURDATE() function. Here’s the query:

SELECT CURDATE();

Here’s the result of the query:

2024-11-03

Discussion

Discover the best interactive MySQL courses

Use the CURDATE() function to get the current date.

The date can be displayed in two different formats: 'YYYY-MM-DD' (if it is used as a string) or YYYYMMDD (if it is used as a numeric).

What does it mean to be used in a string or numeric context? Let’s see an example of a query in a string context:

SELECT CURDATE();

And the result:

2024-11-03

An example of a query in a numeric context:

SELECT CURDATE() + 0;

Which will result in:

20241103

There are two other functions that can be used instead of CURDATE(): CURRENT_DATE and CURRENT_DATE(). All three are synonyms; that is, you can choose any of them and the result will be the same.

Recommended courses:

Recommended articles:

See also: