AnsweredAssumed Answered

Field calculator, subtract Expiry date from the Current Date

Question asked by alang on Feb 12, 2013
Latest reply on Feb 25, 2013 by alang
I am new to Python and not a programmer. I wish to use the field calculator to subtract an "Expiry Date" from the current date. I have used the following code (which works), but it is using a field containing the current date. How do I change this code so it uses only one field and subtracts from the current date?
Many thanks

import datetime
def NoDays(d1, d2):
  c1 = datetime.datetime.strptime (d1.split () [0], "%Y/%m/%d")
  c2 = datetime.datetime.strptime (d2.split () [0], "%Y/%m/%d")
  n = (c1 - c2).days
  return n

NoDays( !Expiry! , !Current!)