Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

SQL spilt all rows into 2 columns

I have a SQL .mdf database and date-time is combined but I want split them from ‘ ‘ space

I have a SQL .mdf database and date-time is like

Date-Time
2021-01-20 12:30:51.000
2021-01-12 12:23:46.000

I want to create 2 new columns and split Date-Time from ‘ ‘ space to this 2 new columns

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Date-Time Date Time
2021-01-20 12:30:51.000 2021-01-20 12:30:51.000
2021-01-12 12:23:46.000 2021-01-12 12:23:46.000

how can I do this from SQL Server Management Studio

>Solution :

Select FORMAT([date-time], 'yyyy-MM-dd') AS[Date],
FORMAT([date-time], 'HH:mm:ss:m0') AS [Time]
FROM YourTable 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading