I am having a problem inserting a date value into a column of a new row I am adding to a table called SiteDay. The LinkID is added just fine. I have set the DateAdded field as a DATE field (I also tried setting it to TIMESTAMP, but the format is not what I want).
Now, I have read the documentation regarding Date Types at http://www.mysql.com. It seems that the default value of 0000-00-00 cannot be overridden. But this doesn't make sense because date values are added just fine in other tables using the DATE field type. I've also looked at other Links SQL scripts as references to see how the date field is added.
Here is what I have tried so far:
1) Added the following codes before the INSERT codes:
$today = $SITEDB->get_date;
$in->param ( -name => 'DateAdded', -value => $today );
2) I have also tried using the following INSERT codes:
$sth = $SITEDB->prepare ("SELECT 1 FROM SiteDay WHERE LinkID = $id");
$SITEDB->do ("INSERT INTO SiteDay (LinkID,DateAdded) VALUES ($id,$today)");
AND
$sth = $SITEDB->prepare ("SELECT 1 FROM SiteDay WHERE LinkID = $id");
$SITEDB->do ("INSERT INTO SiteDay (LinkID) VALUES ($id)");
I am at a lost...I do not know why the date insertion is not working.
Any suggestions are welcome.
Thanks in advance.
Regards,
Eliot Lee
Now, I have read the documentation regarding Date Types at http://www.mysql.com. It seems that the default value of 0000-00-00 cannot be overridden. But this doesn't make sense because date values are added just fine in other tables using the DATE field type. I've also looked at other Links SQL scripts as references to see how the date field is added.
Here is what I have tried so far:
1) Added the following codes before the INSERT codes:
Code:
$today = $SITEDB->get_date;
$in->param ( -name => 'DateAdded', -value => $today );
2) I have also tried using the following INSERT codes:
Code:
$sth = $SITEDB->prepare ("SELECT 1 FROM SiteDay WHERE LinkID = $id");
$SITEDB->do ("INSERT INTO SiteDay (LinkID,DateAdded) VALUES ($id,$today)");
AND
Code:
$sth = $SITEDB->prepare ("SELECT 1 FROM SiteDay WHERE LinkID = $id");
$SITEDB->do ("INSERT INTO SiteDay (LinkID) VALUES ($id)");
I am at a lost...I do not know why the date insertion is not working.
Any suggestions are welcome.
Thanks in advance.
Regards,
Eliot Lee