2 answers
Hi,Trying using below method and let us know if it works. public boolean isDateInRange(Date startDate, Date endDate, Date userDate){
// Assuming endDate is always greater than startDate
if(userDate < startDate){ // less than start date, not in range
return true;
}else if(userDate > endDate){ // greater than end date, not in range
return true;
}else if(userDate > startDate && userDate > endDate){ // greater than both
return true;
}else if(userDate > startDate && userDate < endDate){ // in range
return false;
}
}
Date userDate =Date.newInstance(2018, 11, 31);
Date startdate =Date.newInstance(2017, 1, 31);
Date enddate =Date.newInstance(2017, 12, 31);
if(userDate < startDate || endDate > userDate )
{
system.debug('True');
}else
{
system.debug('false');
}