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
 SQL Server Development (2000)
 Insert Time problem

Author  Topic 

TAS
Yak Posting Veteran

65 Posts

Posted - 2003-11-28 : 15:05:11
I use Convert(char(24),GetDate(),108) to insert time to table, but it always gives me something like '1900-01-01 14:59:19.000'(1900-01-01 in front of time).Does anybody tell why?

nr
SQLTeam MVY

12543 Posts

Posted - 2003-11-28 : 15:53:56
It doesn't. datetimes are stored as 2 binary fields. The first is the number of days since 1 jan 1900.

For display the datetime is converted to a character value and if you display the date (0) you will see 1 jan 1900.
You can format it to display just the time if you wish.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

SqlStar
Posting Yak Master

121 Posts

Posted - 2003-11-29 : 03:25:59
If you want to store exact time value only, change your column datatype as "Varchar(8)" instead of "Datetime".

":-) IT Knowledge is power :-)"
Go to Top of Page

nricardo
Starting Member

17 Posts

Posted - 2003-12-01 : 13:45:38
but Varchar(8) won't function correctly if calculations are needed
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-12-01 : 13:48:07
nricardo, if you store the time portion in a datetime column, it will also add a date to it. To not see the date, use the CONVERT function when you SELECT the data.

Tara
Go to Top of Page

Granick
Starting Member

46 Posts

Posted - 2003-12-01 : 14:09:36
Anyone else notice that we have had a seemingly large number of date questions as of late?

Shannon
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-12-01 : 14:15:48
Yukon might help these "user" problems as it will have a date data type and a time data type.

Tara
Go to Top of Page

Granick
Starting Member

46 Posts

Posted - 2003-12-01 : 17:14:26
Now the only issue would be, how long after Yukon comes out, will we finally get to switch to using it.

Shannon
Go to Top of Page
   

- Advertisement -