1

I have one column in my Table with DateTime as its datatype. Now I would like to remove the date part from the datetime column, and update the same column with only time part contained in it. How should I proceed?

Below is the column value :

1900-01-01 01:43:00.000

Expected value after update would be :

01:43:00.000
jarlh
  • 42,561
  • 8
  • 45
  • 63
Abhi
  • 341
  • 1
  • 6
  • 23
  • This question has already been answered: http://stackoverflow.com/questions/2449552/how-to-get-time-hhmmss-from-sql-query – Maiko Kingma Aug 13 '15 at 06:50

2 Answers2

2

If you use SQL Server from version 2008 onwards you can use

SELECT CAST('1900-01-01 01:43:00.000' as TIME)

For earlier versions, use

SELECT CONVERT(VARCHAR(20),'1900-01-01 01:43:00.000',108)
Madhivanan
  • 13,470
  • 1
  • 24
  • 29
0

You can use this query for getting time from datetime format.

select cast(yourdatetimecol as time) [time] from yourtable

R.Rajesh
  • 1
  • 4