Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fractastical/989780 to your computer and use it in GitHub Desktop.
Save fractastical/989780 to your computer and use it in GitHub Desktop.
@fractastical string to SOQL DateTime
try {
queryString += ' where Start_Date_Time__c > ';
startDate = String.escapeSingleQuotes(startDate); //Protection against SOQL Injection
String[] s = startDate.split('/');
for (Integer i=0;i < s.size();i++)
if (s[i].length()==1)
s[i] = '0' + s[i];
queryString += s[2] + '-' + s[0] + '-' + s[1] + 'T00:00:00Z';
whereUsed=true;
}
catch (Exception e){
ApexPages.Message m = new ApexPages.Message(ApexPages.Severity.WARNING, 'Start Date is in the wrong format');
ApexPages.addMessage(m);
}
// salesforce blog: http://www.d3developer.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment