Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Take only Seconds from DateTime column

Status
Not open for further replies.

jasonhuibers

Programmer
Sep 12, 2005
290
CA
1900-01-01 13:01:45.002

In my sql select statement how can I return only the time poertion of the column? In this case: 13:01:45.002

 
Hi;

You can use convert function here.

******************************

Select Convert(varchar(20) , cast('1900-01-01 13:01:45.002' as datetime) , 114)

******************************

Thanks
Essa

 
Hi;

Just for your reference, you can play with datepart function as well to make get your required part of the datetime:

select datepart(yy, '1900-01-01 13:01:45.002')
select datepart(m, '1900-01-01 13:01:45.002')
select datepart(dd, '1900-01-01 13:01:45.002')
select datepart(hh, '1900-01-01 13:01:45.002')
select datepart(mm, '1900-01-01 13:01:45.002')
select datepart(ss, '1900-01-01 13:01:45.002')
select datepart(ms, '1900-01-01 13:01:45.002')

Thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top