[thelist] date time query

Joshua Olson joshua at waetech.com
Thu Jul 29 00:20:47 CDT 2004


> -----Original Message-----
> From: Mark Groen
> Sent: Thursday, July 29, 2004 12:58 AM
>
> I can't seem to get a query to work as expected:
>
> INSERT INTO bowenonline (id, datestamp, thread, parent, author,
> subject, email)
> SELECT id, CONCAT(postdate + time) AS datestamp, thread, parent,
> author, subject, email FROM forum;
>
> The datestamp field gets populated with the default 0000-00-00
> 00:00:00 instead of something like 1999-01-01 12:01:01. The datestamp
> field is a DATETIME type and the postdate is DATE and time is TIME.
> Anything obvious I might be missing here?

Mark,

Hmmm... which database would this be?  One thing to look at would be the
CONCAT function.  If you are concatenating the strings with the + operator,
I don't see why you'd need the CONCAT method.  Perhaps it should be
CONCAT(postdate, ' ', time)?  I think you are using MySQL, and I'm not a
MySQL guru, but do check that you can implicitly convert between date and
time types to string, and back from a string to datetime automatically like
this.

HTH,

<><><><><><><><><><>
Joshua Olson
Web Application Engineer
WAE Tech Inc.
http://www.waetech.com/service_areas/
706.210.0168




More information about the thelist mailing list