I am trying to set up a model to do a task that I do every month. Part of that model is a stand-alone python script that creates a file name with the date tagged on to the end of it. How do I write my script so that it returns this string and I can use it as input for another geoprocessing tool? I have searched the forums and help, but can't find any examples of this.
Are you trying to use the current date or a date that you want to set?
If so, try importing datetime, create the date and then pass it to a string variable. From there, build your file name and concatenate your string date variable where you want it.
x = str(yourdatevariable)
Here are some good examples on how datetime works.
Thanks for the quick responses. After looking into the output parameter, I have added my script to the model as a script tool and created an output parameter as a string type. The file name is hard coded into the script, so I don't have any parameters in the script. Do I need to create one for the setParameterAsText? Can you point me to some examples of what the a script with an output parameter looks like and I can figure out how to plug it into the model?
See Setting script tool parameters. It appears you want a single derived output parameter, so pay particular attention to the write-ups about derived output parameters.
Thanks everyone for your help. Thanks for that link Dale, that is what I needed to get what I was calling a return value. I created a derived output string parameter for my script tool and added this line to the end of my script: arcpy.SetParameterAsText(0, fileName).