+ Start a Discussion
JBabuJBabu 

How to get the records which belong to current and next year

Hi,

 

I have a date field called "Schedule_Date__c".

 

I tried the below query:

 

select id, name from Opportunity_Division where Schedule_Date__c >= CURRENT_YEAR.

 

I am getting the error message "unexpected token: CURRENT_YEAR"

 

Please let me know what the issue is?

 

Thanks,

Babu.

Best Answer chosen by Admin (Salesforce Developers) 
SFAdmin5SFAdmin5

this works

 

SELECT Id,Schedule_Date__c FROM Opportunity_Division__c WHERE (Schedule_Date__c >= THIS_YEAR OR Schedule_Date__c >= NEXT_YEAR)

All Answers

SFAdmin5SFAdmin5

you said your query is this

 

select id, name from Opportunity_Division where Schedule_Date__c >= CURRENT_YEAR

 

Opportunity_Division is not a standard object.  Shouldn't it be select id, name from Opportunity_Division__c where Schedule_Date__c >= CURRENT YEAR

SFAdmin5SFAdmin5

this works

 

SELECT Id,Schedule_Date__c FROM Opportunity_Division__c WHERE (Schedule_Date__c >= THIS_YEAR OR Schedule_Date__c >= NEXT_YEAR)

This was selected as the best answer
JBabuJBabu

Thank you.

it was my typo to mention as "Opportunity_Division"

 

I thought CURRENT_YEAR would do but thanks for letting me know the usage of THIS_YEAR.