Fearpig Posted May 17, 2007 Share Posted May 17, 2007 Hello, I'm having a problem with an SQL datetime field. The field is set to allow nulls and that it has no default value but when I submit the PHP form the datetime field gets updated to 01/01/1970 12:00:00:00 AM. Can anyone tell me whats going on!? I want to have the null values! Thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/51843-date-field-defaults-to-01011970/ Share on other sites More sharing options...
Psycho Posted May 17, 2007 Share Posted May 17, 2007 Dates are set with a timestamp that is n seconds from a baseline date, in this case the one you see above. I suspect your query is setting the date with a null string when the date has no value. Instead try changing the query so that it is not setting the date at all or use NULL. Post the code you use to build/run the query for more help. Quote Link to comment https://forums.phpfreaks.com/topic/51843-date-field-defaults-to-01011970/#findComment-255480 Share on other sites More sharing options...
kenrbnsn Posted May 17, 2007 Share Posted May 17, 2007 Please post the code that updates the database. Ken Quote Link to comment https://forums.phpfreaks.com/topic/51843-date-field-defaults-to-01011970/#findComment-255481 Share on other sites More sharing options...
Fearpig Posted May 17, 2007 Author Share Posted May 17, 2007 Hi Guys, Here's the code I use for the update, all of the variables are captured using $_POST['Field_Name']. <?php $sql_Insert="UPDATE tbl_Attendees SET Payment_Recieved='$date_PR_formatted',Payment_Method='$Payment_Method',Confirmation_Date='$date_CD_formatted',Training_Pack='$date_TP_formatted',Certificate_Date='$date_Cert_formatted' WHERE Person_ID='$Person_ID' AND Course_ID='$Course_ID'"; $Insert_Details=odbc_exec($conn,$sql_Insert); if (!$Insert_Details) {exit("Error in SQL");} ?> Quote Link to comment https://forums.phpfreaks.com/topic/51843-date-field-defaults-to-01011970/#findComment-255491 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.