I'm using ArcGIS 10.1 and have a field containing a date and time I need to get the day of the week based on my date field and also when the same field that contains date and time
I need to do this from the field calculator
example
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityIn your new field use the field calculator with the following script code in the Field Calculator window:
def dayOfWeek(dField):
dow = datetime.datetime.strptime(dField , '%d/%m/%Y %I:%M:%S %p').strftime('%A')
return dow
dayOfWeek(!DateField!)
The %A
returns the day of the week, as in Monday, Tuesday, etc. This can be changed per your requirements using the codes shown on this page.
The date format in strptime()
may need to be modified to match your date settings - the geoprocessing results window can help debug what kind of date is being passed if it does fail.
weekday
that does this. If you need something else you need to be more specific with your question.