# Calculating Quarter (Q1, Q2, etc) using Date field in ArcMap Field Calculator?

I am using ArcMap 10.0 and making a map where I symbolize on annual quarter (i.e. Q1 2013, Q2 2013, and so on by quarter through 2015).

If a date field contains this: 01/15/2013, and I wanted to create a new field called QUARTER, that would contain the quarter in which the date falls, how could I do that?

Right now I'm just definition querying a range of dates, but surely there is a way to just calculate Quarter, right?

-
Is the date field text or date field type? – artwork21 Feb 25 '13 at 19:59

This python field calculator script should work:

``````def checkValue(field):
myMonth = int(field.split('/')[0])
myYear = field.split('/')[2]
if myMonth <=3:
return 'Q1-' + myYear
elif myMonth >= 4 and myMonth <=6:
return 'Q2-' + myYear
elif myMonth >=7 and myMonth <=9:
return 'Q3-' + myYear
else:
return 'Q4-' + myYear
``````

Hope that helps.

-
You could simplify that a bit further by using `if myMonth <=3: elif myMonth <=6: elif myMonth <=9: else:` – kenbuja Feb 25 '13 at 21:31
@kenbuja, Good point! – artwork21 Feb 26 '13 at 1:33

Here's a way using integer division:

``````def checkValue(field):
m,d,y=field.split('/') #assumes date in some backward MM/DD/YYYY format, what's with that? ;)
q=(int(m)-1)//3 + 1
return 'Q%s - %s'%(q,y)
``````
-
`mmddyyy` is not defined here. – blah238 Feb 26 '13 at 4:37