Open In App

TO_DAYS Function and WEEK Function in MariaDB

Last Updated : 02 Dec, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
TO_DAYS Function : In MariaDB, TO_DAYS Function converts a date into numeric days. In this function, the first parameter will be the Date. This function returns the numeric days of the date. This function is to be used only with dates within the Gregorian calendar. This function will return NULL if date is '0000-00-00'. It is reverse of FROM_DAYS function. Syntax :
TO_DAYS( date )
Parameter :
ParameterDescription
datedate to convert to numeric days.
Return : It returns date into numeric days. Example-1 :
SELECT TO_DAYS('2014-11-20');
Output :
735922
Example-2 :
SELECT TO_DAYS('2014-11-18 05:30:00');
Output :
735920
Example-3 :
SELECT TO_DAYS('0000-00-00');
Output :
NULL
WEEK Function : In MariaDB, Week Function is used to return the week portion of a date value. In this function, the first parameter will be date value and the second parameter will be mode. This function will return a value between 0-53 or 1-53 depending on the mode specified. This function returns the same as the WEEK function with the syntax of WEEK(date_value, 3). Syntax :
WEEK( date_value, [ mode ] )
Parameters :
ParametersDescription
date valueA date or datetime value from which to extract the week.
modeOptional. It is used to specify what day the week starts on.
Return : It returns the week portion of a date value. Example :
SELECT WEEK('2020-01-05');
Output :
1

Next Article
Article Tags :

Similar Reads