Jump to content


This topic is now archived and is closed to further replies.


SQL error when trying to insert date into database

Recommended Posts



I keep recieving the following error:


"The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value"


everytime I try and enter a date in the format of 12/05/2005 into my DB.


my code looks like


//Grab date for entry into database                            
$day = date("j");
$month = date("n");
$year = date("Y");
$date = date('d/m/Y', mktime(0, 0, 0, $month, $day, $year));
// Retrieve answer to question 1 and display
$booking = $_POST['holdingName1'];
echo ("<b>$booking</b>");
// query to add sigle answered form data into database
$insert_query = "INSERT INTO answers (id, qid, surveyNum, answer, date) VALUES ('$var', '1', '1', '$booking', '$date')";

$result = odbc_exec($connection, $insert_query);


$date returns the format stated above but it wont allow me to enter itno the DB...WHY!!!!!


Please...Please...someone help


Best Regards



Share this post

Link to post
Share on other sites

Hi there!


Please try to post the database layout, that just might provide the answer ...

Share this post

Link to post
Share on other sites

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.