xmunoz / sodapy

Python client for the Socrata Open Data API
MIT License
402 stars 114 forks source link

Apply date filter in where field #86

Closed kevalshah90 closed 2 years ago

kevalshah90 commented 2 years ago

I am trying to apply a date filter in my call like this:

client = Socrata("data.sfgov.org", None, timeout=60)

results = client.get("i98e-djp9", where="YEAR(DATE_FORMAT(permit_creation_date, \"%Y\")) > 2020")

This throws a HTTPError: 400 Client Error: Bad Request.. How do I apply date filter as the columns are not stored as date type?

`Query coordinator error: query.soql.no-such-function; No such function 'DATE_FORMAT'; arity=2; position: Map(row -> 1, column -> 889, line -> "SELECT `permit_number`, `permit_type`, `permit_type_definition`, `permit_creation_date`, `block`, `lot`, `street_number`, `street_number_suffix`, `street_name`, `street_suffix`, `unit`, `unit_suffix`, `description`, `status`, `status_date`, `filed_date`, `issued_date`, `completed_date`, `first_construction_document_date`, `structural_notification`, `number_of_existing_stories`, `number_of_proposed_stories`, `voluntary_soft_story_retrofit`, `fire_only_permit`, `permit_expiration_date`, `estimated_cost`, `revised_cost`, `existing_use`, `existing_units`, `proposed_use`, `proposed_units`, `plansets`, `tidf_compliance`, `existing_construction_type`, `existing_construction_type_description`, `proposed_construction_type`, `proposed_construction_type_description`, `site_permit`, `supervisor_district`, `neighborhoods_analysis_boundaries`, `zipcode`, `location`, `record_id` WHERE YEAR(DATE_FORMAT(`permit_creation_date`, '%Y')) > 2020\n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ^")`