I have datetime column value below
2015-01-04 20:37:00.000
I tried below
cast(cast(MyDateColumn as date) as datetime)+cast(datepart(hour,MyDateColumn ) as float)/24
as MyDateColumn
and
CAST(CONVERT(CHAR(16),MyDateColumn,113) AS datetime) as MyDateColumn
These are did not work for me
How can i get above datetime as 01-04.2015 20:37 ?
In MYSQL it will work
In MS SQL It will work
this is the way i do it. I needed to get -2 minutes
In SQL Server this will work:
Since MS SQL 2012, you can use
FORMAT
,Here's another way and you get a datetime in return.
In SQL Server this should do the trick: