Sample Header Ad - 728x90

How to convert correctly from datetime2 data-type to small date and to elliminate HH:mm:SS.000000 padding

0 votes
0 answers
431 views
I have created a table with a column with a date data type which correspond to a date data in yyy-MM-dd format. In the database it presents it as if the data type is datetime2(7). More generally all the date data-types (date, smalldate, datetime) are presented as datetime2(7) even datetime2 with less ms presicions. enter image description here I tried to execute the following query: SELECT CAST('2007-05-08 12:35:29. 1234567 +12:15' AS time(2)) AS 'time' ,CAST('2007-05-08 12:35:29. 1234567 +12:15' AS date) AS 'date' ,CAST('2007-05-08 12:35:29.123' AS smalldatetime) AS 'smalldatetime' ,CAST('2007-05-08 12:35:29.123' AS datetime) AS 'datetime' ,CAST('2007-05-08 12:35:29. 1234567 +12:15' AS datetime2(7)) AS 'datetime2' And I displayed the following table: enter image description here Is there any management settings that stricts the date conversion or alternitavly, is there any more powerful conversion functions to display and store data in the correct data types?
Asked by Zeevik.sha (1 rep)
Aug 9, 2022, 11:25 AM
Last activity: Aug 9, 2022, 11:28 AM