function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
nikita dhamalnikita dhamal 

comparing date values in apex repeat

User-added image
i have 3 date fields sop, sofi, confirmdelivery. as shown in the image i have condition that for dates between sop and sofi i need to show blue color similarly for date between sofi to confirmdelivery display purple color. for this i have given my code below:
 but the problem is it is not considering month of end date. 
is there any way to compare dates in apex repeat or does anyone has any other solution for this??

vf code:
 <apex:repeat value="{!verleih}" var="t">
                        <tr>
                            <td class="anlage">
                                <apex:outputLink value="/{!t.Id}" title="PT System Details" target="_blank">{!t.Name}</apex:outputLink>
                            </td>
                         
                            <td class="anlage">
                                <apex:outputLink value="/{!t.Id}" title="PT System Owner" target="_blank">{!t.Owner.Name}</apex:outputLink>
                            </td>
                            
                            <apex:repeat value="{!weeks}" var="wk">
                            <apex:repeat value="{!wk.days}" var="day">
                            
                            <td align="left" class="{!day.cssname}" valign="top">
                            
                              <apex:variable var="ACTUALDATE" value="{!wk.startingdate}">
                              <apex:variable var="SOFIDATE" value="{!t.SOFI__c}">
                              <apex:variable var="SOPDATE" value="{!t.SOP__c}">     
                              <apex:variable var="CONFIRMDATE" value="{!t.Confirmed_delivery_date__c}">

                              
                              
                                <apex:variable var="dayOf" value="{!DAY(day.date)}">
                                <apex:variable var="monthOf" value="{!MONTH(day.date)}">
                                <apex:variable var="yearOf" value="{!YEAR(day.date)}">
                                <apex:variable var="sofi" value="{!TEXT(t.SOFI__c)}">
                                <apex:variable var="SOP_DAY" value="{!DAY(t.SOP__c)}">
                                <apex:variable var="SOP_MONTH" value="{!MONTH(t.SOP__c)}">     
                                <apex:variable var="SOFI_DAY" value="{!DAY(t.SOFI__c)-1}">
                                <apex:variable var="SOFI1_DAY" value="{!DAY(t.SOFI__c)}">
                                <apex:variable var="SOFI_MONTH" value="{!MONTH(t.SOFI__c)}"> 
                                
                                
                                 <apex:variable var="monthOf1" value="{!MONTH(day.date)+1}"/> 
                                <apex:variable var="CONFIRM_DAY" value="{!DAY(t.Confirmed_delivery_date__c)-1}">
                                <apex:variable var="CONFIRM1_DAY" value="{!DAY(t.Confirmed_delivery_date__c)}">
                                <apex:variable var="CONFIRM_MONTH" value="{!MONTH(t.Confirmed_delivery_date__c)}">                                
                                <apex:variable var="sop" value="{!TEXT(t.SOP__c)}"/>
                                
                                    <apex:variable var="format1" value="{!DAY(day.date)}.{!MONTH(day.date)}.{!YEAR(day.date)}">
                                    <apex:variable var="format2" value="{!DAY(day.date)}/{!MONTH(day.date)}/{!YEAR(day.date)}">
                                    <apex:variable var="format3" value="{!DAY(day.date)}-{!MONTH(day.date)}-{!YEAR(day.date)}">
                                    <apex:variable var="format4" value="{!MONTH(day.date)}/{!DAY(day.date)}/{!YEAR(day.date)}">
                                    <apex:variable var="format5" value="{!YEAR(day.date)}.{!DAY(day.date)}.{!MONTH(day.date)}">
                                    <apex:variable var="format6" value="{!YEAR(day.date)}/{!MONTH(day.date)}/{!DAY(day.date)}">
                                    <apex:variable var="format7" value="{!YEAR(day.date)}-{!MONTH(day.date)}-{!DAY(day.date)}">
                                    
                                    <apex:variable var="d" value="{!CASE(Region,'de',format1,'de_DE_EURO',format1,'de_DE',format1,'uk',format1,CASE(Region,'ca',format2,'es',format2,'fr',format2,'fr_BE',format2,'fr_FR_EURO',format2,'fr_FR',format2,'en_CA',format2,'en_GB',format2,'it',format2,'it_IT',format2,CASE(Region,'da',format3,'da_DK',format3,'nl',format3,'nl_NL',format3,'pt_PT',format3,CASE(Region,'en_US',format4,'es_PR',format4,CASE(Region,'ko',format5,'ko_KR',format5,'hu',format5,'lt_LT',format5,CASE(Region,'ja',format6,'ja_JP',format6,CASE(Region,'fr_CA',format7,'')))))))}" >
                              
       <div style="margin-top:3px;margin-left:3px;z-index:1">
        <apex:outputPanel rendered="{!IF(SOP_DAY!=null && SOFI_MONTH!=null && SOP_MONTH!=null && SOFI_DAY!=null  && CONFIRM_MONTH!=null && CONFIRM_DAY!=null ,'true','false')}">
   
        <a class="{!IF((monthOf >= SOP_MONTH && dayOf >= SOP_DAY ) && (monthOf <= SOFI_MONTH && dayOf <=SOFI_DAY ), 'blue',
        IF(dayOf >= SOFI_DAY && dayOf <=CONFIRM_DAY && monthOf >= SOFI_MONTH && monthOf <= CONFIRM_MONTH, 'violet', 
        IF(dayOf=CONFIRM1_DAY && monthOf =CONFIRM_MONTH,'cross','error')))}" 
        style="hover:text-decoration:none;" href="/{!t.Id}" title="{!d}: PT System '{!t.Name}' for '{!t.Owner.Name}'" target="blank">_____</a> &nbsp;&nbsp;<font size="+1"></font>&nbsp; 
        </apex:outputPanel>
       </div>   
              
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable> 
                           
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            </apex:variable>
                            
                            </td>
                            </apex:repeat>
                            </apex:repeat>
                            </tr>
                    </apex:repeat>