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
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 dayOfWeek(!DateField!)
%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.