1

i want to update a filed named "outofdate"(type date : 2015-01-14 10:03:11 ) based on another filed name "lastmodification" . i want to add 10 days to "outofdate" field where :outofdate < NOW() (actual date)

My code is not working:

Update *
`mytable` set outofdate = lastmodification + 84500*10
WHERE  outofdate < NOW( ) LIMIT 0,100

thx in advance!

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
Rus Sergiu
  • 49
  • 2
  • 10

1 Answers1

1

Update *? That is not valid syntax. I think the rest is basically ok:

Update mytable
    set outofdate = lastmodification + interval 10 day;
    WHERE outofdate < NOW( )
    LIMIT 0, 100;

Note that the number of seconds in a day is not 84,500. Also, for date/time data types, use date_add() or interval addition.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786