Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Insert only Time to DateTime Column ?

Author  Topic 

matkwan
Starting Member

36 Posts

Posted - 2003-11-23 : 20:48:14
Hi,

How do I only insert Time to DateTime Column ?

When I tried this, it gives me 1/1/1900.
Insert into tblAbsence (EventTimeStamp) values ('12:00:00 AM')

Matt

byrmol
Shed Building SQL Farmer

1591 Posts

Posted - 2003-11-23 : 20:52:15
The DateTime data type has both the date and time portions. Simply disregard the date portion.

DavidM

"SQL-3 is an abomination.."
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-11-23 : 20:52:56
There is no way to insert only the time into a datetime column. Specifying only a time will default the date to 1/1/1900, it is normal behavior. If you wish to display on the time portion in a query, look in Books Online under the CONVERT function, it has some formatting codes that will display time portions only.

Yeah, what David said.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-11-24 : 13:29:05
True...

But, it seems you can have (in vb anyway) a time only returned to a variable if the date is stored as 1899-12-30...

Still not sure why...

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=30709



Brett

8-)
Go to Top of Page
   

- Advertisement -