Loading lesson path
Concept visual
Start at both ends
Convert a value to a DATE datatype:
CAST("2017-08-29" AS DATE);The CAST() function converts a value (of any type) into the specified datatype.
See also the CONVERT() function.
value AS datatype )
Required. The value to convert datatype Required. The datatype to convert to. Can be one of the following:
Formula
Converts value to DATE. Format: "YYYY - MM - DD"Formula
Converts value to DATETIME. Format: "YYYY - MM - DD HH:MM:SS"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).
Converts value to TIME. Format: "HH:MM:SS"
Converts value to CHAR (a fixed length string)
Converts value to NCHAR (like CHAR, but produces a string with the national character set)
Formula
Converts value to SIGNED (a signed 64 - bit integer)Formula
Converts value to UNSIGNED (an unsigned 64 - bit integer)Converts value to BINARY (a binary string)
From MySQL 4.0
Convert a value to a CHAR datatype:
SELECT CAST(150 AS CHAR);