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


enter image description here

  • Wouldn't it be much easier to do this in Excel / OpenOffice Calc before you import the spreadsheet into ArcMap? There is a function in Excel called weekday that does this. If you need something else you need to be more specific with your question.
    – dru87
    Feb 17, 2016 at 16:25
  • I agree with @dru87, but you can use the datetime module eg.
    – geodranic
    Feb 17, 2016 at 16:29

1 Answer 1


In 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


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.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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