Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in SQL by (6.1k points)
I have this date format: 2020-09-28 18:01:00 (in varchar), and I need to convert it to datetime changing to this format 28-09-2020 18:01:00.

How can I able to do it?

1 Answer

0 votes
by (12.7k points)
edited by

Use this below code:

SELECT CONVERT(Datetime, '2020-09-28 18:01:00', 120) -- to convert it to Datetime

SELECT CONVERT( VARCHAR(30), @date ,105) -- italian format [28-09-2020 18:01:00]
+ ' ' + SELECT CONVERT( VARCHAR(30), @date ,108 ) -- full date [with time/minutes/sec]

Want to learn more concepts related to SQLJoin this SQL server certification course by Intellipaat.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...