How to get the time for a given datetime value?
I have a datetime in database like this:
2010-09-06 17:07:28.170
and want only the time portion:
17:07:28.170
Is there a function for that or something?
How to get the time for a given datetime value?
I have a datetime in database like this:
2010-09-06 17:07:28.170
and want only the time portion:
17:07:28.170
Is there a function for that or something?
Try this
SELECT CAST(DataField AS time(7)) AS 'time'
You can try the following code to get time as HH:MM format:
SELECT CONVERT(VARCHAR(5),getdate(),108)