Correctly Querying Time field in SOQL

Jared Odulio
1 min readSep 30, 2019

I’m relatively new to Salesforce objects but not new to the concepts of SQL and other relational databases. I found that time-typed field is one of the least documented feature in Salesforce. A time-typed field is simply a field with a time type, not datetime type or Date type. Creating a SOQL script for it should not include a date just a time in this format:

13:00:00.000Z //simply means 1PM regardless of timezone

An example of a SOQL script with a time field criteria:

SELECT Id, Name, Time_Field_1 FROM Some_Custom_Object__c WHERE Time_Field_1 = 10:00:00.000Z

The reason for writing this post is for me remember this solution once the same problem pops up. I’ve spent almost half a day looking for answers in Google and elsewhere.

--

--

Jared Odulio

Developer of really cool apps in Vue and Bulma, Sketcher wannabe, Mercedes-Benz fanatic, SWAG Equities Trader, Certified Securities Representative