Example
Return a binary representation of 15:
SELECT BIN(15);
Definition and Usage
The BIN() function returns a binary representation of a number, as a string value.
Syntax
BIN(number)
Return a binary representation of 15:
SELECT BIN(15);
The BIN() function returns a binary representation of a number, as a string value.
BIN(number)
Return the year and week number for a date:
SELECT YEARWEEK("2017-06-15");
The YEARWEEK() function returns the year and week number (a number from 0 to 53) for a given date.
YEARWEEK(date, firstdayofweek)
Return the year part of a date:
SELECT YEAR("2017-06-15");
The YEAR() function returns the year part for a given date (a number from 1000 to 9999).
YEAR(date)
Return the week number for a date:
SELECT WEEKOFYEAR("2017-06-15");
The WEEKOFYEAR() function returns the week number for a given date (a number from 1 to 53).
Note: This function assumes that the first day of the week is Monday and the first week of the year has more than 3 days.
WEEKOFYEAR(date)
Return the weekday number for a date:
SELECT WEEKDAY("2017-06-15");
The WEEKDAY() function returns the weekday number for a given date.
Note: 0 = Monday, 1 = Tuesday, 2 = Wednesday, 3 = Thursday, 4 = Friday, 5 = Saturday, 6 = Sunday.
WEEKDAY(date)
Return the week number for a date:
SELECT WEEK("2017-06-15");
The WEEK() function returns the week number for a given date (a number from 0 to 53).
WEEK(date, firstdayofweek)
Return the number of days between the date and year 0:
SELECT TO_DAYS("2017-06-20");
The TO_DAYS() function returns the number of days between a date and year 0 (date “0000-00-00”).
The TO_DAYS() function can be used only with dates within the Gregorian calendar.
TO_DAYS(date)
Return a datetime value based on the arguments:
SELECT TIMESTAMP("2017-07-23", "13:10:11");
The TIMESTAMP() function returns a datetime value based on a date or datetime value.
Note: If there are specified two arguments with this function, it first adds the second argument to the first, and then returns a datetime value.
TIMESTAMP(expression, time)
Return the difference between two time expressions:
SELECT TIMEDIFF("13:10:11", "13:10:10");
The TIMEDIFF() function returns the difference between two time/datetime expressions.
Note: time1 and time2 should be in the same format, and the calculation is time1 – time2.
TIMEDIFF(time1, time2)
Convert a time value into seconds:
SELECT TIME_TO_SEC("19:30:10");
The TIME_TO_SEC() function converts a time value into seconds.
TIME_TO_SEC(time)