I'm trying to create a dynamic map title in ArcMap that updates based on current day + 2 days. For example, if I run the code on the 20th of a given month, the title should update to show the 22nd.

I've arrived at two independent, but partial solutions: the first works in pure Python not integrated with ArcMap and the second works using Dynamic Text (but only for the current date). I'm not partial to one method over another, but am not familiar enough with either to arrive at a satisfactory solution. Is anyone aware of a way to use either of these methods to solve the issue?

Partial Solution #1 - Python code

from datetime import date, timedelta
import calendar
publication_date = date.today() + timedelta(days=2)
publication_day_of_week = calendar.day_name[publication_date.weekday()]

#Title format example:
#"Forecast for Thursday March 17"
print "Forecast for " + publication_day_of_week + " " + publication_date.strftime("%B %d")

Running this script as of today (March 17, 2016) correctly yields the text "Forecast for Saturday March 19"

Partial Solution #2 - ArcMap Dynamic Text tags

<dyn type="document" property="title"/> <dyn type="date" format="dddd MMMM d"/">

The title property above represents the text "Forecast for" which is followed by the formatted date.

However, the output is "Forecast for Thursday March 17"-- the current date. As far as I can tell, dynamic text can only use the current date, time, etc., and cannot be used to forecast 2 days out from the current date.

I've already reviewed the following but can't seem to see a complete solution:

1) http://pro.arcgis.com/en/pro-app/help/layouts/date-and-time-dynamic-text.htm

2) https://geonet.esri.com/thread/21281

3) Dynamic title in ArcMap

  • Instead of text box create small dataframe with say 1 point. Label point using datetime.date.today() + datetime.timedelta(days=2) – FelixIP Mar 17 '16 at 23:48
  • @FelixIP I think you should add this as another answer to the duplicate, because it is a perfectly valid workaround too. – PolyGeo Mar 17 '16 at 23:56
  • @PolyGeo I added it to update post – FelixIP Mar 18 '16 at 0:05

Displaying previous and current year with dynamic text? is a duplicate which was asked a couple of years ago and its finding was that text formatting does not support calculations.

To meet a requirement like yours I would use Python to calculate the future date, and then use Pseudo-dynamic Text instead of true Dynamic Text.

In other words, use a standard text element with a string in it that you replace using the contents of your Python variable.

| improve this answer | |
  • There are often workarounds, see my comments above – FelixIP Mar 17 '16 at 23:50
  • @FelixIP I always forget about the workaround that you mentioned, and yet I use it myself, and find it very useful, in Writing Python AddIns for Family HiStory Maps using ArcGIS for Desktop to write past dates (and other items) along the top. – PolyGeo Mar 17 '16 at 23:54
  • 1
    @FelixIP I just remembered why I did it your way there, it was because I needed to be in Data View, so there were no layout elements that I could update. – PolyGeo Mar 17 '16 at 23:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.