HOW TO

Export layers with a current date in the output layer name in ModelBuilder

Last Published: June 17, 2022

Summary

Adding a current date to the output layer name enables users to generate daily layers and keep track of updated data. In ModelBuilder, the output layer name generated automatically contains the current date.

Procedure

The instructions provided describe how to export layers with a current date in the output layer name using ModelBuilder in ArcMap and ArcGIS Pro:

In ArcMap

  1. In ModelBuilder, add the Calculate Value function by clicking Insert > Model Only Tools > Calculate Value.
The Calculate Value function in ModelBuilder.
  1. In the Calculate Value dialog box, add the following expression:
time.strftime("<LayerName>%Y%m%d")
  1. In the Calculate Value dialog box, change the Data type parameter to String.
The Calculate Value window displaying the Expression and Data type (optional) sections.
  1. Type the %<output parameter name>% in the Output Feature Class section of the tool used.
Note:
Ensure the output parameter name is exactly the same as the Calculate Value tool output name. In this example, the output name of the Calculate Value tool is output_value. Therefore, the output parameter name in the Output Feature Class section must be %output_value%.
In the Copy Features window, add %output_value% in the output name.
  1. Click Connect The Connect button. and link the output from Calculate Value to the selected geoprocessing tool, and select Precondition.
Connect and select Precondition in ModelBuilder.
  1. Validate and run the model. The output layer name with the current date is located in the selected location.
The completed model in the Model window.
The output named New_Layer_Name20180907.

In ArcGIS Pro

  1. On the ModelBuilder tab on the top ribbon, add the Calculate Value function by clicking Utilities > Calculate Value.
On the ModelBuilder tab, click Utilities and click Calculate Value.
  1. In the Calculate Value dialog box, add the following expression:
time.strftime("<LayerName>%Y%m%d")
  1. In the Calculate Value dialog box, change the Data type parameter to String.
  2. In the Model window, double-click the geoprocessing tool used, and type %<output parameter name>% in the Output Feature Class section.
Note:
Ensure the output parameter name is exactly the same as the Calculate Value tool output name. In this example, the output name of the Calculate Value tool is output_value. Therefore, the output parameter name in the Output Feature Class section must be %output_value%.
The tool's window displaying the Output Feature Class parameter. Click OK after naming the output.
  1. Click the output of Calculate Value, and link it to the selected geoprocessing tool. Select Precondition.
In the Model window, click the output and select Preconditional.
  1. Validate and run the model. The output layer name with the current date is located in the selected location.
The Model window displaying the complete model ready to run.
The output layer named New_Layer_Name20180907 in the geodatabase folder.

Article ID:000018085

Software:
  • ArcMap
  • ArcGIS Pro

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic