[thelist] Insert Time Only into DateTime Field?

Canfield, Joel JCanfield at PacAdvantage.org
Sat Jun 24 01:03:21 CDT 2006


> I cannot find the answer on Google.  How did you insert time only
> without date?

more or less off the top of my head, so this is subject to review :)

depends on the db, I suspect, but with MS SQL you simply insert a date
('2006-06-23') or a time ('23:07:38') and the db leaves the missing part
blank. A date appears in the db with the time as all zeroes; a time
appears with the date as 1900-01-01 (is it 1901?)

Then, to retrieve just the populated portion, a query similar to this:

    select CONVERT(char(10),EventDate,101) as 'EventDate',
Right(e.starttime,7) as 'StartTime'

If you're using MS SQL, research converting datetime data types to know
what the '101' is, and what other options there are.

spinhead



More information about the thelist mailing list