Adding Date to Field in Model Builder

988
4
05-10-2022 03:49 PM
SaraJCourter
New Contributor II

I'm trying to add an inline variable to my feature class to add the date. I know that adding %t% will add in the date and time, but I only want to add the date. Specifically, I would like this model to pump out the feature class with the current date (the date the tool is run on) in the format YYYYMMDD. Is there a quick solution besides me just having it as a parameter? 

0 Kudos
4 Replies
KimGarbade
Occasional Contributor III

I hope this helps.

KimGarbade_0-1652267228313.png

time.strftime("%y%m%d")
0 Kudos
SaraJCourter
New Contributor II

For some reason, I can't find the Calculate Value tool. Also, I need the year in YYYY (2022)

0 Kudos
KimGarbade
Occasional Contributor III

You can find it under the Utilities menu in the ModelBuilder tab.  Try using a capital Y instead of the lower case one I sent earlier.

KimGarbade_0-1652280166204.png

time.strftime("%Y%m%d")
0 Kudos
AngelaStrongarm
New Contributor II

Can I bring this thread back to life? This is how I went about solving the same issue, but my model throws an error code of "Invalid Characters" whenever I try to name an export with the inline variable that I created... 

AngelaStrongarm_0-1694023322966.png
This is my code block for that Calculate Value field ...

AngelaStrongarm_1-1694023443359.png

 

 

0 Kudos