0

I have a field on a custom setting which is of the type DateTime. I have a business requirement where I need to use this value in conditional SOQL of one SObject.

If I try to use Select Id, myField__c FROM MySampleObject__c WHERE SystemModStamp > myDateTimeValue , the SOQL statement throws compile time error.

Is it some data type issue or is it not comparable to variables?

1 Answer 1

2

It is comparable with DateTime variables, you just forgot colon that bind variables need in SOQL:

Select Id, myField__c FROM MySampleObject__c WHERE SystemModStamp > :myDateTimeValue

Notice that in the query, the bind variable is preceded by a colon ( : ).

1
  • Ah, that was such a simple miss. Thanks. This solved the issue. Commented Jun 30, 2021 at 5:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .