How can I 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 can I 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?
6条答案
按热度按时间zf9nrax11#
Just to add that from SQL Server 2008, there is a TIME datatype so from then on you can do:
Might be useful for those that use SQL 2008+ and find this question.
cl25kdpy2#
In case of SQL Server, this should work
iqjalb3h3#
Try this:
See time (Transact-SQL).
yizd12fk4#
Assuming the title of your question is correct and you want the time:
ugmeyewa5#
In SQL Server 2008 and later
vmdwslir6#
You can try the following code to get time as HH:MM format: