michalis

Field Calculator in Python using Dates

Discussion created by michalis on Feb 3, 2012
Latest reply on Feb 3, 2012 by michalis
I have a field in my shapefile that is of type "Date".

I want to figure out the difference between that "Date" and today, in weeks.

My assumption was that (datetime.date() - !Date!) would produce a timedelta object, which i would simply call to find out the difference. Hence my code below:

(datetime.date.today() - !Date!).days / 7


Of course, that says it is a syntax error, which doesn't explain much. Any pointers to manipulating dates in the field calculator?

Outcomes