SECOND Function and SYSDATE Function in MariaDB
Last Updated :
27 Nov, 2020
1. SECOND Function :
In MariaDB, The SECOND Function returns the second portion of a date value. In this function, the first parameter will be the date/DateTime. This function returns the seconds (a number from 0 to 59) given a date value. In this function, we will pass the date value in it and it will return the second of the date as result.
Syntax :
SECOND( date_value )
Parameter:
- date_value – A date or DateTime value from which to extract the second.
Return :
It will return the second portion of a date value.
Example-1:
SELECT SECOND('10:06:23')-SECOND('2020-05-19 09:19:02.000004');
Output:
21
Example-2:
SELECT SECOND('01:02:22')+SECOND('02:10:06');
Output:
28
Example-3:
SELECT SECOND('14:01:26');
Output:
26
Example-4:
SELECT SECOND('2020-05-19 09:19:02.000004');
Output:
2
Example-5:
SELECT SECOND('2018-10-11 12:20:23');
Output:
23
Example-6:
SELECT SECOND('838:10:59');
Output:
59
Example-7:
#The Curdate() function will return the current time of the system date
SELECT SECOND(CURDATE());
Output:
19
2. SYSDATE Function :
In MariaDB, The SYSDATE Function is used to return the current date and time. In this function, No parameter will be passed. For the string context, this function will return the current date as a ‘YYYY-MM-DD HH:MM: SS’ format. And for the numeric context, this function will return the current date as a YYYYMMDDHHMMSS format.
Syntax:
SYSDATE()
Parameter:
- NA – No parameter will be passed in this function.
Return:
Return the current date and time
Example-1:
SELECT (SYSDATE()+12)-SYSDATE();
Output:
12
Example-2:
SELECT SYSDATE();
Output:
'2020-11-08 10:27:21'
Example-3:
SELECT SYSDATE() + 10;
Output:
20201108102731
Example-4:
SELECT SYSDATE() - 15;
Output:
20201108102706
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...