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

SQL Server/VB/Time

Status
Not open for further replies.

Fursten

Programmer
Dec 27, 2000
403
PT
Hi,

What is the best way to insert in a SQL Server field the hours:minutes:seconds?

The best I get it was to define a varchar field and then insert the time as text.

If the datatype of the field was datetime, SQL will always add the date part...

On the othet hand, if I have a dateTime field how can I select only the time of that field (directly using SQL without using VB functions)

Thank you.

Sérgio Oliveira

 
Hi,

But a dateTime field keeps the date and time... not only the time.

Even if I use that option, I would like then to get only the time when I´m selecting that field...

Thanks
 

Use the datetime data type. You'll find it useful when you get around to searching or filtering on that field. Stick the whole thing in and use the Convert function, with a datatype of varchar and a style of 8 or 108 to get just the time back. A search for 'CONVERT' in the SQL Server Books Online will give you the syntax.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top