Open In App

CURDATE() and CURRENT_TIME() in MariaDB

Last Updated : 20 Oct, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will discuss CURDATE and CURRENT_TIME function, and also, we will see the working of both functions with the help of an example.

1. CURDATE :
In MariaDB, The CURDATE Function is used to return the current date. In this function, no parameter will be passed. This function will return the current Date. This function works similarly to the CURDATE function. If it is used in a string context. then it will return the current date in the ‘YYYY-MM-DD’ format. If it is used in a numeric context. then it will return the current date in the YYYYMMDD format.

Syntax :

CURDATE( )

Parameters :
No parameters or arguments will be passed for the CURDATE function.

Example-1 :

SELECT CURDATE();

Output :

'2020-10-17'

Example-2 :

SELECT CURDATE() + 0;

Output :

20201017

Example-3 :

SELECT CURDATE() + 2;

Output :

20201019

2. CURRENT_TIME :
In MariaDB, The CURRENT_TIME Function is used to return the current time. In this function, no parameter will be passed. This function will return the current time. This function works similarly to the CURTIME function. If it is used in a string context. then it will return the current time in the ‘HH:MM: SS’ format. If it is used in a numeric context. then it will return the current time in the HHMMSS format.

Syntax :

CURRENT_TIME( )

Parameters :
No parameters or arguments will be passed for the CURRENT_TIME function.

Example-1 :

SELECT CURRENT_TIME();

Output :

'07:25:28'

Example-2 :

SELECT CURRENT_TIME()+4;

Output :

072532

Example-3 :

SELECT CURRENT_TIME()+0;

Output :

072528

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads