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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date time query

Status
Not open for further replies.

nelco

Programmer
Apr 4, 2006
93
US
I have this date as
start_dte_tme: '11/3/2005 2:00:00 PM'and
end_dte_tme: '1/1/2007 4:00:00 PM'

I need to extract hour from start_dte_tme as 14 and end_dte_tme as 16.
I tried this:
convert(varchar(10), start_dte_tme, 108)as 'from',
convert(varchar(10), end_dte_tme, 108)as 'to',

This gives as 14:00:00 and 16:00:00. I need only 14 and 16.

Also I need to extract only date from date time stamp.

I will appreciate any help.
Thanks, Nelco
 
Anyways - I used this
DATEPART ( hh , start_dte_tme ) and that worked.
Thanks, Nelco
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top