Select to view content in your preferred language

Dynamic date for yesterday

6848
15
Jump to solution
12-09-2015 10:10 PM
MarkPratt
Deactivated User

I am producing some maps and I want the date on the map to be yesterdays date, as the data on the map relates to yesterdays progress.

I can only find in the dynamic date help section how to show this with today's date, when I want today-1.

Any ideas?

Mark Pratt

Western Geco

Tags (2)
0 Kudos
15 Replies
LukeSturtevant
Frequent Contributor

Are you using data driven pages? If you are then you can use Wes Miller's code in a display expression for your data driven page layer like so:

def FindLabel ( ):
    from datetime import date, timedelta
    return date.strftime(date.today() - timedelta(days=1), '%m/%d/%Y')

Then in your dynamic text element you would use this:

<dyn type="page" property="expression" />

This works for me and should update automatically for all your maps since it uses the current date code.

MarkPratt
Deactivated User

Luke

Sad to say that they are not data driven pages but separate MXD files.

0 Kudos
LukeSturtevant
Frequent Contributor

Well you could still set up data drive pages especially if your maps are all consistent and using an index polygon layer for paneling such as a town boundary polygon. You could also set up a fishnet​ of your map area to create a panel scheme. But if you already have it up and running with the text element and python script tool you might as well stick with that.

0 Kudos
WesMiller
Deactivated User

Luke, the code was from Jon Morris

0 Kudos
LukeSturtevant
Frequent Contributor

Oops thanks for the correction Wes. Indeed, credit goes to Jon Morris for the code.

0 Kudos
JonMorris2
Frequent Contributor

Thanks! I didn't know much about text elements, so I've learned something here too 🙂