Hello. I have the following code that works fine when there is not a record with a date/time of midnight. However today I came across a record at a time of midnight and it breaks the script. Is there a way around this? Thank you. I have provided a screenshot of the attributes. Both fields are date fields.
Error: ValueError: time data '12/16/2019' does not match format '%m/%d/%Y %I:%M:%S %p'
<SPAN class="comment token"># Add CST date/time field</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Adding CST date field"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddField_management<SPAN class="punctuation token">(</SPAN>mergedFCSquaresDis<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"DATE_CST"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Date"</SPAN><SPAN class="punctuation token">)</SPAN>
expression <SPAN class="operator token">=</SPAN> <SPAN class="string token">"datetime.strptime(!DATE_UTC!,'%m/%d/%Y %I:%M:%S %p') + timedelta(hours=-6)"</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>CalculateField_management<SPAN class="punctuation token">(</SPAN>mergedFCSquaresDis<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"DATE_CST"</SPAN><SPAN class="punctuation token">,</SPAN> expression<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"PYTHON_9.3"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>