I seem to be having issues getting a String variable to work. I am attempting to get a Date (formatted as YYYYMMDD) in a String Variable which then gets used as a part of an export filename. I was getting a "1" output instead of the Date originally (and other errors) but now I am managing to get the date but also keep getting errors about incorrect naming. Can anyone tell me what is wrong? The original demo tool I used to figure this out so far (provided here) has the same issue!
Solved! Go to Solution.
Curtis is suggestion that you use the expression that he posted above in your field calculator expression rather than hardcoding the % symbols.
I use python 3.5 so I am not sure what he is expecting as output, but here is what I get
time.strftime(u"zzz{0}d{0}m{0}Y".format(chr(37)))
'zzz12112017' # which appears to be day, month and year of today
I cannot reproduce your issue @ 10.5.1. But: percent signs are significant to ModelBuilder as they delimit ModelBuilder variables. If you have a variable "d" or "m" in your model I could see that breaking things, or maybe you are using a different version of ArcGIS where the parser isn't as smart.
You may be able to avoid this issue by hiding percent signs in your time code string like this using the Python chr() function and string formatting:
time.strftime("zzz{0}d{0}m{0}Y".format(chr(37)))
Update: This is a Calculate Value expression you can use instead of what you're using, which hides the "%" from Model Builder. The strftime function will see this: "zzz%d%m%Y" (the expression chr(37) is equal to "%", which I then substituted in to the expression using the .format() method.
Curtis is suggestion that you use the expression that he posted above in your field calculator expression rather than hardcoding the % symbols.
I use python 3.5 so I am not sure what he is expecting as output, but here is what I get
time.strftime(u"zzz{0}d{0}m{0}Y".format(chr(37)))
'zzz12112017' # which appears to be day, month and year of today
Great! I see where I went wrong. I just copied and pasted the expression Curits provided which was missing a bracket and I didn't notice. Worked perfectly the second time using your's Dan. Thank you both for your help!
Hi mr. Patterson,
your expression helped me but in the end i got table.xls with output name like this:
what else can i do to get output name like the "green bubble" output_value is showing?
thank you.
Open the bubble and enter: %output_value%. The text will be substituted there. Though, you need to provide a folder variable as well so you can give a full path:
%output folder%\%output_value%
Hello
I am having problem to add date to my file
I am getting this error in ArcPro
I am having problem to set copy features output. I tried with code here too