Hi,
How do I Pull the data based on two dates in Python from ArcGIS Online?
The below code works for single date:
feature_layer_id = ''
Inspform = gis.content.get(feature_layer_id)
from datetime import datetime, timedelta
insp=Inspform.layers[0].query().sdf #.sdf get as a pandas dataframe
last_24hour_date_time = datetime.now() - timedelta(hours = 3200)
timestamp = last_24hour_date_time.strftime('%Y-%m-%d %H:%M:%S')
filterinsp = insp[insp['CreationDate'] >= timestamp]
sinsp = filterinsp.astype({"SHAPE":str}) #should convert else error
sinsp
I am trying to add another date to compare, the below code doesn't work: It says invalid syntax at OR
from datetime import datetime, timedelta
insp=Inspform.layers[0].query().sdf #.sdf get as a pandas dataframe
last_24hour_date_time = datetime.now() - timedelta(hours = 😎 #replace it with 24 hours and use append ,3200
timestamp = last_24hour_date_time.strftime('%Y-%m-%d %H:%M:%S')
filterinsp = insp [ [insp['CreationDate'] >= timestamp] OR [insp['EditDate'] >= timestamp] ]
sinsp = filterinsp.astype({"SHAPE":str}) #should convert else error
sinsp
Code formatting ... the Community Version - Esri Community
will get rid of that cool emoji in your code and provide line numbers to help others
Are you sure OR isn't lowercase (eg. or )