Salesforce : Converting DateTime to format YYYY-MM-DDThh:mm:ssZ

I spend lots of my time finding a solution for converting the datetime into the format (YYYY-MM-DDThh:mm:ssZ) so that it can be used in SOQL query.  SOSL query returns the datetime in format(YYYY-MM-DDThh:mm:ssZ) so for comparison one need to convert it into that format.


I hope this will save your time. 🙂

One thought on “Salesforce : Converting DateTime to format YYYY-MM-DDThh:mm:ssZ”

  1. This was helpful, but doesn’t give the time in GMT.

    It should read:‘yyyy-MM-dd\’T\’hh:mm:ss\’Z\”)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.