<Today_date>T00:00:00.000+0000 is not returned when TODAY is used in Where clause

39 Views Asked by At

I am inserting record with scan_date as <Today_date>T00:00:00.000+0000, but I am not able retrieve the same using scan_date = TODAY (SOQL).

example:

There is record with scan_date = "2022-01-10T00:00:00.000+0000", but the record is empty when I queried

SELECT Id  FROM <Table_name> where Scan_Date__c=TODAY

But I am retrieve the same data by using query

SELECT Id  FROM <Table_name> where Scan_Date__c=YESTERDAY

BTW I am using JsForce with nodeJS.

1

There are 1 best solutions below

0
Suvel Rathneswar On

I solved using DAY_ONLY()

I used the DAY_ONLY() with Scan_Date__c to just compare the date and ignore the time.

SELECT Id  FROM <Table_name> where DAY_ONLY(Scan_Date__c)=TODAY

Reference

  1. https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_date_functions.htm#