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

Convert function for times 1

Status
Not open for further replies.

TeriCoombes

Technical User
Aug 26, 2004
22
US
I have been looking for a conversion style number that will change my datetime field from 1/1/1900 03:00:00 to 03:00 (hh:mm). Everything I have seen so far are styles that will change my field to hh:mm:ss. What I am trying to ask is if there is a style code for just hh:mm? Any help would be appreciated.
 
Unless you put a SUBSTRING command around your CONVERT and Style option, there is no default Sytle that will just give you the Hours and Minutes alone. SO ... it "may" look something like ...

Code:
SELECT SUBSTRING(CONVERT(VarChar,GetDate(),114),1,5)

Of course, swap GetDate() w/ your date field. The above example will work in Query Analyzer though!

Thanks

J. Kusch
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top