I am trying to calculate a "day of the year" field in a feature class using ArcPy.
<SPAN class="comment token">###create day update cursor</SPAN>
cursorD <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>UpdateCursor<SPAN class="punctuation token">(</SPAN>featureclass<SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"month"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"day"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"dayoftheyear"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"day cursor set"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">###loop and assign day of the year</SPAN>
<SPAN class="keyword token">for</SPAN> updateRowD <SPAN class="keyword token">in</SPAN> cursorD<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="string token">'month'</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Jan"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="string token">"dayoftheyear"</SPAN> <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>day<SPAN class="punctuation token">]</SPAN>
cursorD<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>updateRowD<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Jan completed"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">elif</SPAN> <SPAN class="string token">'month'</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">2</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Feb"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="string token">"dayoftheyear"</SPAN> <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>day<SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="number token">31</SPAN>
cursorD<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>updateRowD<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Feb completed"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">elif</SPAN> <SPAN class="string token">'month'</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">3</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Mar"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="string token">"dayoftheyear"</SPAN> <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>day<SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="number token">59</SPAN>
cursorD<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>updateRowD<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Mar completed"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>and continues throughout the rest of the year (April through December). I'm getting syntax errors on the lines where I actually calculate the day number (lines 9, 14, 19, etc). I just can't figure out the syntax to get it to read the value of a field (day), perform basic arithmetic on it, and assign it to another field (dayoftheyear). I've used lots of combinations of [day], "day", !day!, etc and haven't been able to find my answer in any documentation.
Thanks in advance for your time and suggestions.