shareplum
shareplum copied to clipboard
Shareplum query does not consider datetime
trafficstars
I have the following issues when trying to query the SharePoint list with a DateTime variable. I have Sharepoint 2016 and Python 3.8
- It throws exception when trying to pass a datetime variable in the query.
from requests_ntlm import HttpNtlmAuth
from shareplum import Site
import datetime
url= "https://myCompanySP.net/sites"
last_extract_date = datetime.datetime(2021, 3, 8, 1, 30, 0)
cred = HttpNtlmAuth("domain\\user","password")
site = Site(url, auth=cred, verify_ssl=False)
query = {'Where' : [('Gt', 'Modified', last_extract_date)]}
sp_list = site.List('My List Name')
data = sp_list.GetListItems('All Items', query=query)
TypeError : Argument must be bytes or unicode, got 'datetime'
- So I used a string to pass as datetime in the query, this time it runs without any error but only extracts based on the date and ignores the time part.
query = {'Where' : [('Gt', 'Modified', '2021:03:08 01:30:00')]}