jasonrollins / shareplum

Pythonic SharePoint
MIT License
179 stars 96 forks source link

Shareplum query does not consider datetime #156

Open ompdas opened 3 years ago

ompdas commented 3 years ago

I have the following issues when trying to query the SharePoint list with a DateTime variable. I have Sharepoint 2016 and Python 3.8

  1. 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'

2. 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')]}