MySQL SYSTEM_USER Function

Example

Return the current user name and host name for the MySQL connection:

SELECT SYSTEM_USER();

Definition and Usage

The SYSTEM_USER() function returns the current user name and host name for the MySQL connection.

 

Syntax

SYSTEM_USER()

Continue reading MySQL SYSTEM_USER Function

MySQL YEARWEEK Function

Example

Return the year and week number for a date:

SELECT YEARWEEK("2017-06-15");

Definition and Usage

The YEARWEEK() function returns the year and week number (a number from 0 to 53) for a given date.

Syntax

YEARWEEK(date, firstdayofweek)

Continue reading MySQL YEARWEEK Function

MySQL WEEKOFYEAR Function

Example

Return the week number for a date:

SELECT WEEKOFYEAR("2017-06-15");

Definition and Usage

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.

 

Syntax

WEEKOFYEAR(date)

Continue reading MySQL WEEKOFYEAR Function

MySQL SUBDATE Function

Example

Subtract 10 days from a date and return the date:

SELECT SUBDATE("2017-06-15", INTERVAL 10 DAY);

Definition and Usage

The SUBDATE() function subtracts a time/date interval from a date and then returns the date.

Syntax

SUBDATE(date, INTERVAL value unit)

OR:

SUBDATE(date, days)

Continue reading MySQL SUBDATE Function

MySQL DAYNAME Function

Example

Return the weekday name for a date:

SELECT DAYNAME("2017-06-15");

Definition and Usage

The DAYNAME() function returns the weekday name for a given date. Continue reading MySQL DAYNAME Function

MySQL CURTIME Function

Example

Return current time:

SELECT CURTIME();

Definition and Usage

The CURTIME() function returns the current time.

Note: The time is returned as “HH-MM-SS” (string) or as HHMMSS.uuuuuu (numeric).

Continue reading MySQL CURTIME Function

MySQL LN Function

Example

Return the natural logarithm of 2:

SELECT LN(2);

Definition and Usage

The LN() function returns the natural logarithm of a number.

Note: See also the LOG() and EXP() functions. Continue reading MySQL LN Function

MySQL DIV Function

Example

Integer division (10/5):

SELECT 10 DIV 5;

Definition and Usage

The DIV function is used for integer division (x is divided by y). An integer value is returned. Continue reading MySQL DIV Function