Let’s suppose you are executing the given queries in SQL Server.
1) SELECT CAST('2020 03 01' AS SMALLDATETIME)
Here Missed date separators.
2) SELECT CAST('2020-01' AS SMALLDATETIME)
Here Missed Day part in Date.
3) SELECT CAST('2020 januftru 01' AS SMALLDATETIME)
Error Message:
But getting the below error.
Msg 295, Level 16, State 3, Line 1 Conversion failed when converting character string to smalldatetime data type.
Causes:
In above SQL statement, Date and Time values are being converted from a string to a SMALLDATETIME data type and SQL Server cannot perform the conversion due to an incorrectly formatted date/time values.
Solution of the Error:
To avoid this error, make sure that the character string containing the date/time value is a valid date/time that can be converted to SMALLDATETIME data type.
Solution of above Queries:
1) SELECT CAST('2020-03-01' AS SMALLDATETIME)
2) SELECT CAST('2020-01-01' AS SMALLDATETIME)
3) SELECT CAST('2020 january 01' AS SMALLDATETIME)
Output :
1) (No column name)
2020-03-01 00:00:00
2) (No column name)
2020-01-01 00:00:00
3) (No column name)
2020-01-01 00:00:00
If you want to sell your readymade software to the genuine clients or businessman, list your software with details and demo links.
Clients will find it using our advanced search filter and will contact you directly.
No any charge for the product lsiting.