Page 1 of 1

Insert query whats wrong with it

Posted: Fri Feb 18, 2005 9:30 am
by mohson
Could someone please tell me whats wrong with my insert query - it worked perfectly but once I tried to incorporate my DATE_FORMAT code it stoped working - the date format code itself works fine as when I print results with the select query it works properly. its just I need to incorporate it into my insert as well - there is probably just something wrong with the order can anyone help.

Code: Select all

"INSERT INTO people 
			(person_id,org_id, salutation, 
			firstname, surname, organisation, role, 
			address1, address2, city, postcode, telephone, 
			mobile, fax, dateoflastcontact, datecontactagain, 
			notes, email)
	


 	VALUES 
			('$person_id','$org_id','$salutation',
			'$firstname','$surname', '$organisation', 
			'$role', '$address1', '$address2', '$city', 
			'$postcode', '$telephone', '$mobile', '$fax', 
			'$dateoflastcontact', '$datecontactagain', 
			'$notes', '$email')
		
	DATE_FORMAT(dateoflastcontact, '%d/%m/%y') 
		AS dateoflastcontact, DATE_FORMAT(datecontactagain, '%d/%m/%y') 
		AS datecontactagain 
			
					"; 
ї\code]

Posted: Fri Feb 18, 2005 9:37 am
by feyd
your date format code is outside the insertion syntax.

Why do you want to store the date in a nonstandard way?

Posted: Fri Feb 18, 2005 10:15 am
by Maugrim_The_Reaper
You can simply store the timestamp in an int(11) field - if you need any specific format, apply it a later stage through php's date() function... MySQL has it's own date type field but a timestamp as basic as it gets...

Posted: Fri Feb 18, 2005 10:58 am
by mohson
Feyd, I want to insert the date in UK format which is dd-mm-yy which is how I have set the Date format could you show me how to make my code above work - as in which order to write it in??

Posted: Fri Feb 18, 2005 3:50 pm
by feyd
if you are using a mysql date type, it must be inserted in using their format. When selecting the data, you can format the date in whatever form you wish.