I am trying to select a specific day in the "Select by attributes" tool. I know you can select using a day from 0-31 like this:

EXTRACT(DAY FROM "TimeStampStart") = 5

But I was wondering is there a way to select a specific day in the week (sunday to saturday)? for example select only days of week = tuesday?

P.S This is not the answer I am looking for: https://pdgisusers.org/2010/12/15/extract-day-of-the-week-from-a-date-field-in-arcgis/

and already looked into this :http://support.esri.com/technical-article/000011531

I have a csv file with a datetime field. g

  • Could you post a sample CSV file?
    – Berend
    Commented Jul 12, 2016 at 14:16
  • added to the main
    – Golan
    Commented Jul 12, 2016 at 16:50
  • Could you post a sample CSV file as text?
    – Berend
    Commented Jul 13, 2016 at 7:04

1 Answer 1


If you want to use some Python, it's pretty simple to extract the day of week. There's some limitations working with csv, but the following should be a good starting point:

table = "test.csv"

# list of days to extract, starting with Monday at 1
days = [1,2,3,4,5]

# First field is unique key field used for select, second is date field
# Would be "OID@" if a GDB table
fields = ['Field1', 'Field2']

# Find all key field values
keys = [k for k,d in arcpy.da.SearchCursor(table, fields)
            if d.isoweekday() in days]

# Make new view with selection, export, etc.
sql = "{} IN ({})".format(fields[0], ",".join(map(str, keys)))
arcpy.MakeTableView_management(table, "selection", sql)

It would be trivial to create a toolbox script that takes a csv and day(s) of week as input (maybe even the field names as well).

  • Thanks for the answer. but this isn't what I am looking for, is there a way to use sql inside arcgis in select table to get the day of the week?
    – Golan
    Commented Jul 12, 2016 at 20:43
  • @Golan, I don't believe it is possible if you are using csv. Might not be possible in a GDB table either.
    – Paul
    Commented Jul 12, 2016 at 21:27
  • even though its a date type field? if I use the convert time field tool I can create a new field with the days and select it. but thats not what I am after. anyways thanks
    – Golan
    Commented Jul 12, 2016 at 21:40
  • @Golan, if you look at your initial link, not every database supports the different queries. csv is still just a flat file, so your querying capabilities will be quite limited. What are you looking to use this csv for? Would be simpler to pre-process in python for example and then bring into ArcMap.
    – Paul
    Commented Jul 12, 2016 at 21:57
  • I have 15 files, each one of them has 4-5 million rows. Each file has samples for unique dates. I am buidling a tool in model builder and I am trying the fastest way to select only Saturday and wednesday from those files. Since selecting those days isn't possible as a simple query I now need to check all the dates for all the days I need to query (Dates for saturdays and wednesdays) in the meantime Ive manage to use this query: EXTRACT(DAY FROM "Field4") = 13. 13 is just an example for lets say 13.7 (wednesday)
    – Golan
    Commented Jul 12, 2016 at 22:04

Your Answer

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

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