My goal is to create a daily automated task using a model built from ArcGIS ModelBuilder, then exported to Python script. I would like the outputs of this model to have the name (Stat_) + today's date: "Stat_20170216"

I was able to do this in ModelBuilder with an in-line variable but would like this operation to work in the exported python script.

Here's a bit of Code from the script, with "Stat_%Date%" as the output name.

# Process: Summary Statistics
arcpy.Statistics_AddressModel(StandAdd_Done_View__2_, Stat_Date_, "StandAdd_Done.ADD_SN2 COUNT", "StandAdd_Done.ADDR_HN")

I'm a novice with Python.


You need to get today's date, and then format it as a string in the format you want.

>>> todayDate = datetime.date.today().strftime("%Y%m%d")
>>> print todayDate

You can incorporate this into your code:

todayDate = datetime.date.today().strftime("%Y%m%d")
arcpy.Statistics_AddressModel(StandAdd_Done_View__2_, todayDate, "StandAdd_Done.ADD_SN2 COUNT", "StandAdd_Done.ADDR_HN")
  • Worked like a charm!
    – Jbarne
    Feb 16 '17 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.