UPDATE blogs SET start_date = '11/27/2012 00:00',end_date = '11/27/2012 00:00' WHERE id='9'
This query won’t store start_date or end_date values for blog id 9 unless I set them to varchar type.
Tried with timestamp and date time but the query allways will return that 0 rows where affected
the thing is I need to be able to check for rows in a interval of time, and with varchar it makes very complicated.
What am i missing?
As stated in Date and Time Literals:
Therefore, the strings
'11/27/2012 00:00'and'11/27/2012 00:00'are not valid MySQL datetime literals. You have two options (in some vague order of preference, without any further information of your requirements):Provide your literals in a recognised format:
Use MySQL’s
STR_TO_DATE()function to convert the string: