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 ?
How can I get time without seconds in SQL? it is always stored the only thing you can do is to edit the value before it gets posted so the seconds (and also the milliseconds which are also stored) are set to 0. I suggest you to use two columns for: Hour & Minute ;).
How do you get just the time from a DateTime in SQL? SELECT GETDATE();– Output: 2019-03-31 08:12:08.600. SELECT CAST('2019–03–31 08:12:08.600' AS TIME)– Output: 08:12:08.6000000. SELECT CONVERT(VARCHAR(10), CAST('2019–03–31 08:12:08.600' AS TIME), 0)– Output: 8:12AM.
Use CASTSELECT CAST(getdate() AS date);
Since MS SQL 2012, you can use FORMAT
,
SELECT FORMAT([MyDateColumn], 'dd-MM.yyyy HH:mm')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With