Skip to content
Advertisement

SQL DATIME convert issue

I have a column that displays data in the following format:

2017-10-11T14:00:56.000+0200

I want to display the date in this desired format:

2018-07-31 13:11:11

The column in the base table is of type NVARCHAR.

Please help

Advertisement

Answer

You can try something like this:

SELECT DATE_FORMAT(charDt, '%Y-%m-%d %h:%i:%s'), charDt
FROM (
    SELECT '2017-10-11T14:00:56.000+0200' AS charDt
) z

but horse is right about not storing datetimes as strings. That’s why there’s a datetime format. And you should also include at least the kind of database you are using and ideally sample data.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement