I would like to modify the following accumulative/sequential python code sample in field calculator in a Date Time field. I think this is the correct code to use but let me know if not. The Date Time field is formatted like so: 30/01/2015 18:30:00. I need to add increments of 162 seconds to the time portion of the value for 24 records. The date will not change.
Here is the code sample copied from http://ift.tt/1z2RfTE and I've put my field name 'Date_Time) in
Expression: accumulate(!Date_Time!)
Expression Type: PYTHON_9.3
Code Block: total = 0 def accumulate(increment): global total if total: total += increment else: total = increment return total
I know that I can change a single row's Date_Time value once by running this syntax in field calculator: DateAdd ("s", 162, [Date_Time] ) but I need to loop through the values in the Date_Time column starting with 30/01/2015 18:30:00 for the first row and adding 162 seconds to the new total each time.
Aucun commentaire:
Enregistrer un commentaire