MySQL CONVERT() Function
Example
Convert a value from one datatype to another datatype:
SELECT
CONVERT("2017-08-29", DATE);
Try it Yourself »
Definition and Usage
The CONVERT() function converts a value from one datatype to another, or one character set to another.
Tip: See also 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:
|
||||||||||||||||
charset | Required. The character set to convert to |
Technical Details
Works in: | MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0.2 |
---|
More Examples
Example
Convert a value from one datatype to another datatype:
SELECT CONVERT(150, CHAR);
Try it Yourself »
Example
Convert a value from one datatype to another datatype:
SELECT CONVERT("14:06:10", TIME);
Try it Yourself »
Example
Convert a value from one character set to another:
SELECT
CONVERT("W3Schools.com" USING latin1);
Try it Yourself »