pil0706

Convert Date attribute to Quarter

Discussion created by pil0706 on Mar 15, 2012
Latest reply on Mar 15, 2012 by m.gasior
I have feature classes have "Date" fields in date format and some of them are in String.
I'd like to convert them to Quarter and this is what i wrote...
please comments what parts got wrong and if anyone has better idea for codes, please let me know

# Process: Calculate Field

TESTING = if "Date" <= 03/31/2000 then 1
if "Date" >= 04/01/2000 and "Date" <= 06/30/2000 then 2
if "Date" >= 07/01/2000 and "Date" <= 09/30/2000 then 3
else 4

arcpy.CalculateField_management(Input_Feature, "Quarter", TESTING, "PYTHON", "")


and what if i have years thru 2000 - 2010 and want to convert them once, how do i code it ?
or is there way that i can only use the month and date and ..process for another years?

Outcomes