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
 Development Tools
 Other Development Tools
 ASP - How To Insert ONLY time stamp, not date

Author  Topic 

hismightiness
Posting Yak Master

164 Posts

Posted - 2004-06-23 : 09:29:30
The server seems to automatically adding the date "1/1/1900" when I attempt to enter only a time value into the DB. How can enter only the TIME via ASP (VBScript). We are running SQL Server 2000.

- - - -
- Will -
- - - -

gpl
Posting Yak Master

195 Posts

Posted - 2004-06-23 : 11:59:03
The way that dates and times are stored is as a number of milliseconds since an origin date (1/1/1900, midnight)

so just a time returns a time on that start date

use the '108' datetime format to retrieve the time part only, eg
select
..... fieldlist,
Convert(char(8), MyDatetimeValue, 108) As TimeOnly
From mytable etc

Graham
Go to Top of Page

hismightiness
Posting Yak Master

164 Posts

Posted - 2004-06-23 : 13:15:36
Thanks for the reply. However, do you happen to have a VBScript version of your example?

- - - -
- Will -
- - - -
Go to Top of Page

gpl
Posting Yak Master

195 Posts

Posted - 2004-06-23 : 17:21:28
Sorry, no - I always (well almost always) use stored procedures to retrieve my data then play with the returned values in the ASP.
However if you post what script you are using that returns the '1/1/1900 hh:mm' Ill show you what to change to get just the time.

Graham
Go to Top of Page

hismightiness
Posting Yak Master

164 Posts

Posted - 2004-06-23 : 19:20:37
Well, the applications use this field in different ways depending on which part of the application you are in. However, I have found a work-around to assist me while I am migrating these applications to SQL (then later to VB.Net).

I have changed the field to a varchar datatype. This has so far allowed the applications to function properly. Thanks for replying! :D

- - - -
- Will -
- - - -
Go to Top of Page
   

- Advertisement -