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

How can I insert time in datetime without Date

Status
Not open for further replies.

mooniron

Programmer
Dec 15, 2002
26
TR
Would you please how to put time like hh:mm:ss into datetime column without date info. When I want to insert time into datetime column sql server automatically adds 1:1:1900 next to my time info. But I want only the time info to be inserted! Thanks and best wishes...
 
Hi,

In a datetime filed u cannot store only timestamp..... but u can use SQL to only retrieve only the timestamp. try these SQLs

select convert(varchar(10),datefld,108) from tbl

select convert(varchar(12),datefld,114) from tbl

Sunil
 
SQL server does not support a time datatype. The option you have is to use a varchar column.
 
Mooniron, Is the time you're working with a time-of-day or an elapsed-time? If it's time-of-day I would go with Sunil's suggestion - for elapsed then perhaps an integer value for minutes or seconds might be appropriate. swampBoogie's idea is best if you're not anticipating a need to do any type of calculations with it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top