You need to sign in to do that
Don't have an account?

How to compare two Date fields
Hi all,
So I am trying to create a Trigger that will pull the Opportunity Owner's Quota for the month that the Opportunity closes in and then populate a custom field called Owner_Quota__c on the Opportunity.
I have been trying to run a query on the Revenue Forecast object that pulls the Opportunity Owners Quota if the following conditions are met:
RevenueForecast = rf
Opportunity = o
rf.OwnerId = o.OwnerId
// I need to limit the Quota to the month that the Opp closes in
MONTH(rf.StartDate) = MONTH(o.CloseDate)
// I need to limit the Quota to the year that the Opp closes in
YEAR(rf.StarteDate) = YEAR(o.CloseDate)
I would include more code, but I can't even save my trigger because I have so many different ways that I am trying to do this.
Any help would be appreciated since I can't find very much info on the Revenue Forecast object pertaining to triggers. Let me know if you need to more info.
Thanks,
Alex
I am not able to get your issue correctly could you please if ou want to compare two date field values then it can be directly compared like this
Date d = date.today();
Date d1 = date.today();
system.debug('*************** Compare Date : ' + (d == d1));
It will give you
DEBUG|*************** Compare Date : true in debug logs
You can comepare Date, Month or Year paart separately also using like
d.Month() == d1.Month()
Please let me kow if you want to ask something else.