MySQL DATE_FORMAT problem
Posted: Fri Jan 02, 2009 6:32 pm
Am trying to let my users submit Dates in the UK format e.g. 29/09/1978 into my MySQL table "job" via this update string:
I can nicely change the display format for when the result is later published, using
but what I can't figure out is how to post new data into the table. using PHPMyAdmin I can effectively modify a record like this:
but can't get the syntax right to convert the entry put in by the user. I've tried this: without success
It gives me no error message, just doesn't update the record at all - it resets it to its Default which is 0000-00-00. I've now searched for hours using forums and googling but the MySQL documentation does not contain examples that illustrate how I can tackle this. Can anyone help?
Code: Select all
"UPDATE job SET practice = '$practice', date_posted = CURRENT_TIMESTAMP, job_start_date = '$job_start_date', job_end_date = '$job_end_date', contact = '$contact', session_visible = '$session_visible', accepted_by = '$accepted_by', job_details = '$job_details' WHERE id='$id' "Code: Select all
DATE_FORMAT('$job_start_date', '%d/%m/%Y');Code: Select all
UPDATE `job` SET `job_start_date` = '$job_start_date' WHERE `id` = 1;Code: Select all
UPDATE `job` SET `job_start_date` = DATE_FORMAT('$job_start_date', '%d/%m/%Y') WHERE `id` = 1;