I am trying to create a dynamic text box for today's date plus or minus a number of days. In ArcMap the Python string for the expression was:
(str( datetime.date.today() - datetime.timedelta(days=8))) + ' to ' + (str( datetime.date.today() - datetime.timedelta(days=2)))
I haven't been able to recreate this in Pro. It is for a map and report run daily where we want to have the date range listed as "Today - 8 days to Today - 2days", or 4/21/21 to 4/27/21 for today 4/29/21.
Solved! Go to Solution.
Becca, with a little digging and team help, the following may be your solution (without having to use a Python script to update the value).
On layout, insert Dynamic Text --> Value
Click on the Value to open the Insert Table Attribute dialog.
Set the table to be the index layer (doesn't really matter)
Click the expression button next to field
and set the expression to:
var relDate = Now();
var start = DateAdd(relDate, -8, "days");
var end = DateAdd(relDate, -2, "days");
Text(start, 'M/D/Y') + ' to ' + Text(end, 'M/D/Y');
Hello Becca,
Can you please provide a screenshot of where you set this in ArcMap? I tried in both ArcMap and Pro and could not get this to work.
Jeff - arcpy.mp and Layout teams
Yes, for reference I did not make this map originally, but am trying to recreate/replicate in Pro. The text has this for properties
And then I found the "expression" in the Display Properties for the layer that the data driven pages runs off of.
Let me know if that isn't quite clear, or you need anything else, really appreciate the help!
Becca, with a little digging and team help, the following may be your solution (without having to use a Python script to update the value).
On layout, insert Dynamic Text --> Value
Click on the Value to open the Insert Table Attribute dialog.
Set the table to be the index layer (doesn't really matter)
Click the expression button next to field
and set the expression to:
var relDate = Now();
var start = DateAdd(relDate, -8, "days");
var end = DateAdd(relDate, -2, "days");
Text(start, 'M/D/Y') + ' to ' + Text(end, 'M/D/Y');