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 to Insert Time into DateTime fieldtype

Status
Not open for further replies.

shultz

Programmer
Oct 28, 2001
42
HK
I have a field called NotifTime in a table whose data type is "DateTime". I don't want to insert any date in this but only Time. So, when I give the SQL as

Insert into <TableName> Values('10:10')

It inserts the value as 1/1/1900 10:10:00 AM

Is it possible to insert only the time part.

Please help.

 
No, datetime has 2 parts, date and time ...So if you insert only time SQL will fill in a default date [1900-01-01]; but you can display only time if you like...

Search sql books online for &quot;date functions&quot;.

Try the following command:

select convert(varchar,datepart(hh,getdate())) +':'
+ convert(varchar,datepart(m,getdate())) +':'
+ convert(varchar,datepart(ss,getdate()))


select minute(getdate()),
 
Sorry about the error. Please disregard the last line..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top