Created
May 24, 2011 21:38
-
-
Save fractastical/989780 to your computer and use it in GitHub Desktop.
@fractastical string to SOQL DateTime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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