Posted By

d3developer on 08/06/10


Tagged


Versions (?)

@fractastical string to SOQL DateTime


 / Published in: Other
 

  1.  
  2. try {
  3. queryString += ' where Start_Date_Time__c > ';
  4. startDate = String.escapeSingleQuotes(startDate); //Protection against SOQL Injection
  5. String[] s = startDate.split('/');
  6. for (Integer i=0;i < s.size();i++)
  7. if (s[i].length()==1)
  8. s[i] = '0' + s[i];
  9. queryString += s[2] + '-' + s[0] + '-' + s[1] + 'T00:00:00Z';
  10. whereUsed=true;
  11. }
  12. catch (Exception e){
  13. ApexPages.Message m = new ApexPages.Message(ApexPages.Severity.WARNING, 'Start Date is in the wrong format');
  14. ApexPages.addMessage(m);
  15. }
  16.  
  17. // salesforce blog: http://www.d3developer.com
  18.  

Report this snippet  

You need to login to post a comment.