[thelist] SQL Server smalldatetime field problems

rudy r937 at interlog.com
Tue Jul 10 08:45:24 CDT 2001


> I built the SQL statement using formatDateTime
> to ensure that they were in the correct format.
>
> INSERT INTO motivaction ( ...
>            , motiveDate
>            , motiveStart
>            , motiveFinish
>            , motiveDateBooked )
>   VALUES  ( ...
>          , 'Tuesday, September 10, 2002'
>          , '21:00',
>          , '23:30',
>          , 'Tuesday, July 10, 2001' )

hi norman

i have never ever had problems inserting dates in standard ISO format, e.g.
2001-07-10

maybe it's the Tuesdays -- it's been a while since i've done datetimes, but
the examples in the book i'm using don't use the day of the week in that
format, just the month name, day, and year

does your formatDateTime function claim that it will produce valid datetime
input strings for sql/server?

if so, then maybe it's this second problem --

a datetime field includes both a date and a time

since you are not supplying a time for the motiveDate field, it gets
midnight

but motiveStart is datetime too, and you are only supplying it with a time
('21:00') -- so according to the book i'm using, you should get january 1,
1900

maybe the insert is having a wee problem recognizing '21:00' as a datetime
string

but in any case it seems to me you should combine those two fields

similarly, include a date for motiveFinish, in case it's the next day


rudy







More information about the thelist mailing list