I'm trying to write some code that will filter records from SalesForce that have a value in a field that is not before now. I have given up on trying to format a query that filters the results from SalesForce because not I have tried works and nothing anyone has suggested works (they all return "malformed request"). Although, I'm obviously open to suggestions on that front, too.
So, I have settled on something like this:
now = datetime.now(pytz.UTC)
disables = self.sssvc.query("select Name, Project__c, Ownerid, Id, DisableOn__c, User__c from PIXDisableUserTask__c WHERE Status__c = 'Pending'")
for disable in disables[u'records']:
disable_on = disable[u'DisableOn__c']
if disable_on < now:
continue
else:
disables.pop(disable)
print
return disables
But when I'm done I end up with two incompatible date formats for comparison. The problem is, I don't know how to convert the value of "now" from datetime and "disable_on" from SalesForce into time stamps that can be compared. What I get is something like:
now = 2015-07-29 19:19:07.322224+00:00
disable_on = u'2015-06-24T12:00:00.000+0000'
I know I need to change disable from a string to an actual datetime object in UTC, but I don't know what formula to use.