CONVERT data from one datatype to otherCONVERT function is same as CAST function CONVERT to CHAR
CONVERT to DATEDate format should be in YYYY-MM-DD. Valid date to be used as input. Range for date is '1000-01-01' to '9999-12-31'
CONVERT to TIMETime format should be in HH:MM:SS. Or it can be HHH:MM:SS. Range of time is '-838:59:59' to '838:59:59' as input. If we enter time value beyond this range then output will be limited to this range only.
CONVERT to DATETIMEDate Time format should be in YYYY-MM-DD HH:MM:SS.
CONVERT to DECIMALDecimal with optional values of total digits including number of decimal places. Here DECIMAL ( 5,2 ) mean total digits ( fixed + decimal ) is 5 and decimal places to the right is 2.
CONVERT to SIGNEDSELECT CONVERT(234,SIGNED); // Output is 234 SELECT CONVERT('abc',SIGNED);// Output is 0 SELECT CONVERT('234',SIGNED); // Output is 234 CONVERT to UNSIGNEDSELECT CONVERT(234,UNSIGNED); // Output is 234 SELECT CONVERT('abc',UNSIGNED);// Output is 0 SELECT CONVERT('234',UNSIGNED); // Output is 234 SELECT CONVERT(12-15,UNSIGNED); //Output is 18446744073709551613 SELECT CONVERT(15-12,UNSIGNED); //Output is 3 Storing integer part onlyIn a table we have one column which stores strings like this, Q1,Q2,Q3 …. Q31. Write a query to store the integer part in another integer column.CAST is used to convert string to UNSIGNED number while using ORDER BY query ![]()
This article is written by plus2net.com team.
https://www.plus2net.com
![]() ▼ More on String |