Jan-30-2018, 02:17 PM
If I just want to print out the last day of every month from 2014 through 2017 I can do that no problem with the following code:
Here is the "if" statement:
Why does it not care that "month" is a string in the "print" statement, but it does with the "if" statement?
import arcpy import datetime from datetime import timedelta import time def last_day_of_month(any_day): next_month = any_day.replace(day=28) + datetime.timedelta(days=4) return next_month - datetime.timedelta(days=next_month.day) for year in range(2014,2018): for month in range(1, 13): print (last_day_of_month(datetime.date(year, month, 1)))But when I try and use it in an "if" statement then it wants me to turn "month" from a string into an integer
Error:TypeError: an integer is required (got type str)
.Here is the "if" statement:
if last_day_of_month(datetime.date(year, month, 1)) >= row[3].date(): arcpy.FeatureClassToFeatureClass_conversion(inFeatures, outLocation, outFeatureClass, expression)
Why does it not care that "month" is a string in the "print" statement, but it does with the "if" statement?