daza166 daza166 - 10 months ago 43
MySQL Question

PHP MYSQL update a DATE and TIME field in db manually

I am trying to figure out how to update a MYSQL DATE and TIME field manually (NOT to todays date!)ie set it the date field to a certain date value and time field to a certain time field correctly in the correct SQL required field format.

I am using an UPDATE query not INSERT as my action is to update a users field

Done some research and came up with something along the lines of (obviously this example wont work but does anyone know how to format this query?

UPDATE mytblname SET date='DATE: Manual Date', '2011-06-14'', time='TIME: Manual Time', '12:10:00' WHERE email='somevalue'

If I just enter the value as normal SQL way it gives 0000-00-00 for date and 00:00:00 for time - ie

SET date='2011-06-14',time='12:33:35'

Thanks for any suggestions, really appreciate it!!!

UPDATE mytblname SET `date`="2011-06-14", `time`="12:10:00" WHERE email="somevalue";

This should work fine. Make sure you have the appropriate backticks around date and time.