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.
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: | From MySQL 4.0 |
---|
More Examples
Example
Convert a value to a CHAR datatype:
SELECT CONVERT(150, CHAR);
Example
Convert a value to a TIME datatype:
SELECT CONVERT("14:06:10", TIME);
Example
Convert a value to LATIN1 character set:
SELECT CONVERT("Iampsp.com" USING latin1);