sql - MySQL update with date manipulation from other field -
i have mysql table:
fields: tag duedate
in "tag" field have string conatining date ("mywhatever_20130401").
all rows "tag" "mywhatever_%", need update "duedate" using "20130401" "tag" , adding 14 days , store in format "2013-04-15".
any way 1 query?
you can use right()
function trim characters string based on specified length. before can add 14 days
string, need convert first date using str_to_date()
, eg.
update tablename set duedate = str_to_date(right(tag, 8),'%y%m%d') + interval 14 day tag 'mywhatever\_%'
Comments
Post a Comment