Skip to main content
3 answers
  1. Mar 14, 2016, 5:34 AM
    Hi Balaji,

     

    Please check the below sample code.

    VisualForce Page:

    <apex:page controller="DateRangeCont">

    <apex:form id="dt1">

    <apex:pageBlock >

    <apex:pageBlockSection >

    <apex:pageBlockSectionItem >

    <apex:outputLabel >Start Date</apex:outputLabel>

    <apex:inputfield value="{!a.From_Date__c}"/>

    </apex:pageBlockSectionItem>

    <apex:pageBlockSectionItem >

    <apex:outputLabel >End Date</apex:outputLabel>

    <apex:inputField value="{!a.To_Date__c}"/>

    </apex:pageBlockSectionItem>

    <apex:commandButton value="Go" action="{!go}" reRender="dt"/>

    </apex:pageBlockSection>

    <apex:pageBlockTable value="{!customer1}" var="ct" id="dt">

    <apex:column headerValue="Customer Name">

    <apex:inputField value="{!ct.Name}"/>

    </apex:column>

    <apex:column headerValue="billing city">

    <apex:inputField value="{!ct.Billing_City__c}"/>

    </apex:column>

    <apex:column value="{!ct.createddate}"/>

    <apex:column headerValue="billing postal code">

    <apex:inputField value="{!ct.Billing_Postal_Code__c}"/>

    </apex:column>

    </apex:pageBlockTable>

    </apex:pageBlock>

    </apex:form>

    </apex:page>

    Controller:

     

    public with sharing class DateRangeCont {

    public list<customer__c> customer1 { get; set; }

    public datetime startdate1;

    public datetime enddate1;

    public customer__c a { get; set; }

    public DateRangeCont(){

    customer1=new list< customer__c>();

    a=new customer__c();

    }

    public PageReference go() {

    startdate1=a.From_Date__c;

    enddate1=a.To_Date__c;

    customer1=[select name,Billing_City__c ,Billing_Postal_Code__c,Createddate from customer__c where Createddate>=:startdate1 AND Createddate<=:enddate1];

    return null;

    }

    }

    Screenshot:

    Hi Balaji, Please check the below sample code.

    Hope this helps you!

    Best Regards,

    Jyothsna

     
0/9000