[thelist] MSSQL: adding integer to time yields date?
Luther, Ron
Ron.Luther at hp.com
Mon Nov 28 11:32:18 CST 2005
Joel Canfield asked:
>>I'm trying to use a smalldatetime field as my starting time and
>>an int field as the length in hours to calculate the ending time
>>of an event using VBScript in ASP.
Hi Joel,
Here is a guy fooling with a smalldatetime field:
http://weblogs.asp.net/jasonsalas/archive/2004/07/17/185733.aspx
Looks like the key is working with 'military' time. (The 'feedback'
portion may be more helpful than the actual post.)
As for why you got the 1899 date, ...
***********************************************************
Using '00:05:30' to represent 5 minutes and 30 seconds seems
pretty natural. However, an unfortunate aspect of using the
datetime data type to store timespans is that you must express
any interval that is over one day as a specific date, usually
in 1900. That's why '1900-01-02 10:00:00' is used to represent
one day and ten hours.
***********************************************************
Above snipped from:
http://www.novicksoftware.com/UDFofWeek/Vol1/T-SQL-UDF-Volume-1-Number-3
8-udf_DT_AddTime.htm
So it sounds like your 1899 date is more of a formatting issue
than an error.
HTH,
RonL.
More information about the thelist
mailing list