TimeFilter Class in Python API 1.4.0?

363
2
Jump to solution
03-14-2018 02:21 PM
RianCrowley1
New Contributor

Table.query method supposedly has a TimeFilter parameter, but no definition of TimeFilter object is provided in the documentation.  

Anyone know how to create a TimeFilter object to supply to Table.query()?

https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.features.toc.html#arcgis.features.Table....

time_filter - a TimeFilter object where either the start timeor start and end time are defined to limit the search results for a given time. The values in the timeFilter should be as UTC timestampes in milliseconds. No checking occurs to see if they are in the right format.

0 Kudos
1 Solution

Accepted Solutions
RohitSingh2
Esri Contributor

You can pass in a dict with this format:

{'time': '1510704000000,1514764800000'}

Here is an example you can use to construct this dict:

from datetime import datetime
import time

timerange = [datetime(2017, 11, 15), datetime(2018, 1, 1)]

starttime = int(time.mktime((timerange[0]).timetuple()) * 1000)
endtime = int(time.mktime((timerange[1]).timetuple()) * 1000)

time_filter = {'time' : "%s,%s" % (starttime, endtime)}

View solution in original post

2 Replies
RohitSingh2
Esri Contributor

You can pass in a dict with this format:

{'time': '1510704000000,1514764800000'}

Here is an example you can use to construct this dict:

from datetime import datetime
import time

timerange = [datetime(2017, 11, 15), datetime(2018, 1, 1)]

starttime = int(time.mktime((timerange[0]).timetuple()) * 1000)
endtime = int(time.mktime((timerange[1]).timetuple()) * 1000)

time_filter = {'time' : "%s,%s" % (starttime, endtime)}

RianCrowley1
New Contributor

Thanks, Rohit!

0 Kudos