function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Anil MeghnathiAnil Meghnathi 

Date/Time Formula in Where condition of SOQL query

I tried the following query but it's not working.Any idea will help me.

 

list<BlockedUser__c> bu=new list<BlockedUser__c>();
bu=[select ID,UserID__c,Days__c,Blocking_Date__c from BlockedUser__c where Blocking_Date__c+Days__c>:System.now()];

 

Thanks 

 

Anil

bob_buzzardbob_buzzard

You can't manipultate the field value in the where clause to add another field to it.  The way that I'd handle this is to define a formula field on Blocked_User__c that adds Blocking_Date__c to Days__c and then compare that against the current time.  Also, if your formula returns a date you may need to compare against System.today() rather than System.now().

Anil MeghnathiAnil Meghnathi

Thanks for your reply.

 

I had tried it but it still thowing error.

please can you write that formula which you have implemented

 

 

Thanks

Anil

bob_buzzardbob_buzzard

That's not how these boards work - you post your formula and we'll see if we can figure out what's wrong.