MariaDB Tutorial MariaDB Advanced MariaDB Database Account Management MariaDB References

MariaDB CURRENT_DATE() Function



The MariaDB CURRENT_DATE() function returns the current date. It returns the current date in the following format:

  • Returns the current date as a 'YYYY-MM-DD' format, if used in a string context.
  • Returns the current date as a YYYYMMDD format, if used in a numeric context.

The CURRENT_DATE() function is a synonym for the CURDATE() function.

Syntax

CURRENT_DATE()

Parameters

No parameter is required.

Return Value

Returns the current date.

Example 1:

The example below shows the usage of CURRENT_DATE() function.

SELECT CURRENT_DATE();
Result: '2021-12-26'

SELECT CURRENT_DATE() + 0;
Result: 20211226

SELECT CURRENT_DATE() + 1;
Result: 20211227

Example 2:

Consider a database table called Employee with the following records:

EmpIDNameCityAgeDate_of_Joining
1JohnLondon252018-05-25
2MarryNew York242018-10-15
3JoParis272019-06-09
4KimAmsterdam302019-09-21
5RameshNew Delhi282019-10-25

To insert a new record in this table, the following statement can be used.

INSERT INTO Employee 
VALUES (6, 'Suresh', 'Mumbai', 28, CURRENT_DATE());

-- see the result
SELECT * FROM Employee;

This will produce a result similar to:

EmpIDNameCityAgeDate_of_Joining
1JohnLondon252018-05-25
2MarryNew York242018-10-15
3JoParis272019-06-09
4KimAmsterdam302019-09-21
5RameshNew Delhi282019-10-25
6SureshMumbai282021-12-26

❮ MariaDB Functions