I am retrieving a bunch of values out of one database, trying to fix the format and reinsert into a different master database, which would usually be fine, but 3 of my values are giving me a heck of a time. There are three numeric values in the first DB that I would like to format into a date time and insert into the new DB
#Taking the values one at a time, and assigning to variables $DOBYear = $ayDOB_Year[$i]; $DOBMonth = $ayDOB_Month[$i]; $DOBDay = $ayDOB_Day[$i]; #Concatonating the string $ODBCDate = sprintf("%4d-%02d-%02d", $DOBYear, $DOBMonth, $DOBDay);
Up to hear everything is groovy, but when I try to insert this into the new SQL table I am getting the following error:
Error:Ok so then I tried casting it on the insert statement, and it still isn't working!
$sqlInsert = "Insert into tblMaster (List_Name_, Gender_, First_Name_, + Last_Name_, Full_Name_, Address_1_, City_, State_, Zip_Code_, SCF_Co +de_, Country_, Email_, Domain_Name_, TLD_, DOB_) Values ('$ListName', +'$Gender','$FirstName','$LastName','$FullName','$Address','$City','$S +tate','$Postal','$SCF','$Country', '$Email','$DomainName','$TLD', cas +t('$ODBCDate' as datetime))";
When I print the SQL statement out to the window and paste into SQL it works fine!! Anyone have any insight??
janitored by ybiC: <code> tags around example code, <tt> around error message
In reply to perl dates into string into SQL by jenalice
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |