Clarification on Updating DATE only in DATETIME field
Posted on 2005-03-11
I have looked through the knowledgebase, and see what looks like a solution to my problem, but not being a MySQL guru, I need to make sure as the database I am working on is very sensitive ( I did make a backup first!)
I have a field called key_datetime, which appears as 2005-03-11 10:23:30 (or YYYY-MM-DD HH:MM:SS) and I only need to change the YYYY-MM-DD part, and leave the other part alone since the data that came across had the wrong date, but correct time.
The solution I found (but it is for Microsoft SQL) says:
Set [Field Name] = dateadd(dd,datediff(dd,[Field Name],[Required Date]),[Field Name])
I need clarification on what the dateadd is, the dd (is this a value I am supposed to enter?) and the datediff.
Or should I enter
Update [Table Name]
set key_datetime= dateadd(dd,datediff(dd, key_datetime, 2005-03-11),key_datetime);
After the above I would enter my contstraints of what I wanted to change - only certain dates are wrong.
Thanks for help in advance and I hope someone can answer this quickly for me, I have several thousand records to update!