[thelist] Insert Time Only into DateTime Field?

Ken Schaefer Ken at adOpenStatic.com
Sun Jun 25 01:49:59 CDT 2006


: -----Original Message-----
: From: thelist-bounces at lists.evolt.org [mailto:thelist-
: bounces at lists.evolt.org] On Behalf Of Kristine O'Dea
: Subject: [thelist] Insert Time Only into DateTime Field?
: 
: I cannot find the answer on Google.  How did you insert time only
: without date?

Well, given that you haven't told us what program you what to insert into
(presumably a database, and presumably SQL Server) it's a bit hard to provide
you with specific advice. Likewise, google would probably struggle to tell
you as well if you were so vague.

If this is SQL Server, then the field is a datetime field. It stores a date
*and* a time. You can't store one or the other only. If you insert a date
only, the DBMS will supply a default time, and if you supply a time only, it
will supply a default date. Just ignore the unwanted portion when getting the
values back out again.

Internally SQL Server stores datetimes as a set of numeric values (integers
for datetime). The first int is the number of days since 1/1/1900, and the
second is the number of seconds after midnight. Supplying only a date or time
results in the other portion being assigned a value of "0"

Cheers
Ken

--
My IIS Blog: www.adOpenStatic.com/cs/blogs/ken
Tech.Ed Sydney: learn all about IIS 7.0 - See you there!




More information about the thelist mailing list