function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Apex Controller: public class searchClientVisits{ public List<Client_Visit__c> clientVisitList {get;set;} public Client_Visit__c clientInfo { get;set;} public SearchClientVisits(){ clientInfo = new Client_Visit__c (); clientVisitList =new List<Client_Visit__c>(); } public PageReference runSearch(){ clientVisitList.clear(); if(clientInfo.Start_Date__c != null & clientInfo.End_Date__c != null ){ String startDate=String.valueOf(clientInfo.Start_Date__c).left(10); String endDate=String.valueOf(clientInfo.End_Date__c).left(10); String querystr='SELECT Id,Start_Date__c,End_Date__c,Accounts__c,Clients__c FROM Client_Visit__c WHERE Start_Date__c ='+startDate+' AND End_Date__c='+ endDate; clientVisitList = Database.query(querystr); } return null; } public PageReference reset(){ PageReference pg = new PageReference(System.currentPageReference().getURL()); pg.setRedirect(false); return pg; } } ////////////////////////////////////////////// Visual Force Page: <apex:page controller="searchClientVisits" id="pg"> <apex:form id="frm"> <apex:pageBlock id="pgblk1"> <apex:pageBlockSection id="pgblksec"> <apex:inputField value="{!clientInfo.Start_Date__c}" label="Start Date"/> <apex:inputField value="{!clientInfo.End_Date__c }" label="End Date"/> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton value="Reset" action="{!reset}"/> <apex:commandButton value="Search" action="{!runSearch}" reRender="clientList"/> </apex:pageBlockButtons> </apex:pageBlock> <apex:pageBlock id="pgblk"> <apex:pageBlockTable value="{!clientVisitList}" var="cl" id="clientList"> <apex:column value="{!cl.Accounts__c}" headerValue="Account Name"/> <apex:column value="{!cl.Clients__c}" headerValue="Clients"/> <apex:column value="{!cl.Start_Date__c}" headerValue="Start Date"/> <apex:column value="{!cl.End_Date__c}" headerValue="End Date"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
Please find the sample code below and tweak it as per your requirement which should help. May I also suggest you please check with below links from the community which might help.
- https://developer.salesforce.com/forums/?id=906F0000000BOMeIAO
- https://salesforce.stackexchange.com/questions/114863/how-to-get-records-between-two-date-values
Hope this helps.Please mark this as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
Thanks,
Nagendra.