Wildcard in SOQL python

谁说胖子不能爱 提交于 2021-02-05 11:28:12

问题


I am trying to query from salesforce using python using simple_salesforce package. When I do wildcard, it is throwing me Malfunction error.

soql = """SELECT {} FROM Contact where LastModifiedDate like "%2020-06-16%" """.format(','.join(field_names)) 
results = sf.query_all(soql)

Error

line 1:1374 no viable alternative at character 

回答1:


The date filter is wrong, This field is of type DateTime, not Date

You need to end up with something like

SELECT Id, FirstName, LastName, Email 
FROM Contact 
WHERE DAY_ONLY(LastModifiedDate) = 2020-06-15

Or

WHERE LastModifiedDate >= 2020-06-15T00:00:00Z
    AND LastModifiedDate < 2020-06-16T00:00:00Z

There's a bunch of date conversion functions and special literals (not-really-constants) like TODAY, YESTERDAY, LAST_N_DAYS:123



来源:https://stackoverflow.com/questions/62402924/wildcard-in-soql-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!