+ Start a Discussion
Selvakumar Anbazhagan 7Selvakumar Anbazhagan 7 

Need to convert from formula to SOQL Query

Hi Everyone,

I have a opportunity formula. I need to convert it into a SOQL Query.When i have tried it it throws me parsing error. 
Can anyone help me on this.

My Opportunity formula is :

AND(
  AND(
       ISBLANK(Last_Stage_Change__c),
       NOW() - LastModifiedDate > 30,
       Probability < 0.91,
       Probability > 0.01
      ),
   AND(
       NOW() - Last_Stage_Change__c  > 30,
       Probability < 0.91,
       Probability > 0.01
      )
  )

I have tried this Query as 


select Id,Name,StageName,LastModifiedDate,Last_Stage_Change__c from Opportunity where 
where Last_Stage_Change__c == null and TimeSinceLastModified__c > 30 and TimeSinceLastStageChange__c > 30 and Probability < 91 and Probability > 1

Please any one assist me on this.

Thanks in advane.
William TranWilliam Tran
Can you post the parsing error?

Are all these fields part of the opportunity object?
 
Id,Name,StageName,LastModifiedDate,Last_Stage_Change__c

Also are they of certain types - like they have to be numbers: 
 
and TimeSinceLastModified__c > 30  - has to be a number 
and TimeSinceLastStageChange__c > 30 - has to be a number 
and Probability < 91 - has to be a number 
and Probability > 1 - has to be a number 

Thx