bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

MySQL CONVERT() Function

Concept visual

MySQL CONVERT() Function

Pointer walk
two pointers
leftright102132436485116
left=0
right=6
1
3

Start at both ends

Example

Convert a value to a DATE datatype:

Select

CONVERT("2017-08-29", DATE);

Definition and Usage

The CONVERT() function converts a value into the specified datatype or character set.

Tip:

Also look at the CAST() function.

Syntax

Convert(

value, type )

OR:

Convert(

value

Using

charset )

Parameter Values

Parameter

Description value

Required. The value to convert type Required. The datatype to convert to. Can be one of the following:

Value

Description

Date

Formula

Converts value to DATE. Format: "YYYY - MM - DD"

Datetime

Converts value to DATETIME.

Formula

Format: "YYYY - MM - DD HH:MM:SS"

Decimal

Converts value to DECIMAL. Use the optional M and D parameters to specify the maximum number of digits (M) and the number of digits following the decimal point (D).

Time

Converts value to TIME. Format: "HH:MM:SS"

Char

Converts value to CHAR (a fixed length string)

Nchar

Converts value to NCHAR (like CHAR, but produces a string with the national character set)

Signed

Formula

Converts value to SIGNED (a signed 64 - bit integer)

Unsigned

Formula

Converts value to UNSIGNED (an unsigned 64 - bit integer)

Binary

Converts value to BINARY (a binary string) charset Required. The character set to convert to

Technical Details

Previous

MySQL CONV() Function

Next

MySQL CURRENT_USER() Function