2

I am using ArcGIS 10.1

I'm not a programmer

I want to use the field calculator to add 4 days to the current date if the status is "delivery"

or

subtract 5 days if its status is "order"

this result need to have in the field of "New Date"

Example table

current date 13/11/2014

If the status is "delivery" is new date 16/11/2014

If the status is "order" new date is 09/11/2014

2

I noticed a few irregularities in your example: 1) your date field is actually a text field and 2) your math does not seem to be correct. The following approach should work for you:

In the Pre-Logic Script Code

def correctDate(x,y):
  if x == "delivery":
    newValue = str(int(y.split("/")[0]) + 4)
    a = newValue + "/" +  y.split("/")[1] + "/" + y.split("/")[2]
    return a
  if x == "Order":
    newValue = str(int(y.split("/")[0]) - 5)
    b = newValue + "/" +  y.split("/")[1] + "/" + y.split("/")[2]
    return b

In the box below that:

correctDate(!state!, !current!)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.