Anyone know how to make python put a date stamp on a filename when creating a feature?
Thanks,
Steve
Here is how I had to code it:
import time
from datetime import Date
#Sets a variable to hold today's date
currentdate = today()
Process: Feature Class to Feature Class (6)
arcpy.FeatureClassToFeatureClass_conversion(in, out loc, "output_"+str(currentdate)
The result is: output_2014-10-23
The “-“ causes failure as an invalid character
Good morning Brandon,
I figured out how to send the string to the feature output but the format is 2014-10-23 and I need it to be 20141023. I have read through documentation and have not been able to figure out how to do this format could you please assist?
Yes, that is basically what I am trying to do, I will give that a try and let you know how it goes.
Thanks for your quick responses,
And you would like the date stamp to be on the feature class? So you could check today's "River" export against yesterday's "River" feature class? If I'm understanding you right then I would suggest importing datetime. Depending on how you want to format the date you have some options shown here 8.1. datetime — Basic date and time types — Python 2.7.8 documentation
import datetime
#Set a variable to hold today's date
currentdate = datetime.date.today()
#Execute the feature to feature function. Casting as a string just to be safe
arcpy.FeatureClassToFeatureClass_conversion(in_features, out_path, out_name + str(currentdate))
Hi Brandon,
Yes on a new feature class. I am running a feature to feature script that filters specific data for each feature and I need to date stamp them so that I can view changes in a side by side comparison and the output goes into a File Geodatabase.
Hi Steve,
Can you clarify your question a little? Are you looking to put a date stamp on a new feature class? I've written a few scripts that utilize dates and times and the method changes a little based on where you want to put the data. Let me know and I can try to help.
Brandon
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.