Yesterday I got one query to change numeric value to decimal value. Suddenly I thought "Are datetime and numeric value convertible?" like It convert in excel. Is it possible SQL Server. After 1 hours searching and trial and error , I found result.
The answer is yes.
Here are the main rules on DATATIME and NUMERIC value conversions:
- During the conversion a DATETIME value will be treated as a NUMERIC value with the number of days relative the base date, Jan 1, 1900 being the integer part, and the time of the day being the decimal part.
- DATETIME values can not be converted to NUMERIC values implicitly using assignment operations.
- NUMERIC values can be converted to DATETIME values implicitly using assignment operations.
- DATETIME values and DATETIME values can be converted to each other explicitly using CAST() or CONVERT() functions.
- Implicit conversion Numeric to Datetime
Implicit Conversion Numeric To Datetime
- Explicit conversion NUMERIC to DATETIME
Explicit conversion NUMERIC to DATETIME
- Implicit conversion DATETIME to NUMERIC
Implicit conversion DATETIME to NUMERIC -
Explicit conversion DATETIME to NUMERIC
DECLARE
Explicit conversion DATETIME to NUMERIC DECLARE
No comments:
Post a Comment