Jump to content


SQL error when trying to insert date into database

  • Please log in to reply
1 reply to this topic

#1 stevoh

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 21 December 2005 - 12:51 PM


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


#2 Munchen

  • Members
  • PipPip
  • Member
  • 12 posts

Posted 05 January 2006 - 03:31 PM

Hi there!

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

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users