I have dates (in a date field) of mixed formatting (1/21/2006 4:19:20 AM, 12/27/2007, etc.). I need to populate an integer field with just the year.
Based on this thread I'm trying to work my way through it but I can't get it figured out
d = datetime.datetime.strptime(!InstallDate!, "%d/%m/%Y") justyr = datetime.datetime(d.year)
Any help would be appreciated!
The ArcPy Time module is odd in that most of its functionality isn't documented at all, like the FormatDate method that has no references in the Desktop documentation except one to the old AML FORMATDATE function.
Thanks for mentioning this. I had found the documentation page you linked above, and I wondered why there wasn't a reference to .FormatDate()
How would you grade arcpy documentation overall? While I'm learning more and more about python I anticipate some head scratching along the way, which is of course minimized by good documentation. However, I didn't anticipate struggling so much to find this particular solution, after all finding DatePart('yyyy',[DateField]) is so much easier. I'm interested to hear the opinion of someone experienced.
I would rate the Python/ArcPy documentation as good, reaching towards very good. The documentation is constantly improving, although different parts improve at different paces since different development teams work on their own Python documentation.
lurking behind the time stuff... is the fact that esri hasn't move from python 2 to python 3 completely... so little things like time zone had to be added to the arcpy stuff. However, when one makes the move, all will be good because it has been there for a while
So if you aren't ready... python 2.7 countdown...
then you might want to look at this
don't let time go by