You need to sign in to do that
Don't have an account?
Illegal assignment from date to string
I am trying to return either a string or a date field using the following apex, but i'm getting an error 'illegal assignment from date to string'.
public String RatingRelease {get;set;}
public Date Today {get;set;}
Today = System.today();
//Returns the Rating Release date or the 'rating pending'
IF (Today < currentQRpCase.Rating_Externally_Visible_Date__c){
RatingRelease = 'Rating Pending';
} else IF(Today > currentQRpCase.Rating_Externally_Visible_Date__c){
RatingRelease = currentQRpCase.Rating_Externally_Visible_Date__c;
} else {
RatingRelease = '';
}
public String RatingRelease {get;set;}
public Date Today {get;set;}
Today = System.today();
//Returns the Rating Release date or the 'rating pending'
IF (Today < currentQRpCase.Rating_Externally_Visible_Date__c){
RatingRelease = 'Rating Pending';
} else IF(Today > currentQRpCase.Rating_Externally_Visible_Date__c){
RatingRelease = currentQRpCase.Rating_Externally_Visible_Date__c;
} else {
RatingRelease = '';
}
If you have any issues, please feel free to reach out to me. I hope it helps!
All Answers
If you have any issues, please feel free to reach out to me. I hope it helps!
I tried to run it again using the recommended update above, and now I'm getting a compile error on the first line that the comparison arguments must be compatible types: date, string, and then an error here 'RatingRelease = currentQRpCase.Rating_Externally_Visible_Date__c;' saying illegal assignment from date to string.
//Returns the Rating Release date or the 'rating pending'
IF (Today < currentQRpCase.Rating_Externally_Visible_Date__c.format()){
RatingRelease = 'Rating Pending';
} else IF(Today > currentQRpCase.Rating_Externally_Visible_Date__c){
RatingRelease = currentQRpCase.Rating_Externally_Visible_Date__c;
} else {
RatingRelease = '';
}
I appreciate your help! I"m new :)