I display 20 Records in Visualforce Page, and Created SortBy: Date Button. Once Click the Date Button it should display selected Existing Records and Previous Records, in visualforce page using in Apex custom Controller.

  • 1
    Can you post what did you attempt so far?
    – Reshma
    Oct 10, 2016 at 6:23

1 Answer 1


In your soql querry add Order By createddate, that will work.

  • can u please share any related code for This one..
    – user37856
    Oct 10, 2016 at 6:39
  • You please elaborate what you are currently doing? so that i can be able to tell you what exactly you have to do? Oct 10, 2016 at 7:35
  • @ koustubh kulkarni, i created 20 records in visualforce page , and i can use SoryBy date , i select Date is today , how many records created Today that is display on visualforce page
    – user37856
    Oct 10, 2016 at 7:57
  • So you have to apply filter dynamically. Dynamic SOQL will be better option. You can write basic querry in a string and based on filter criteria selected such as today, two weeks ago you can apply SOQL where part dynamically.e.g Qstr='SELECT Id FROM Account';//here based on your condition put where clasue dynamically//Qstr+='WHERE Name =: accountName';List<Account> accountList = Database.query(Qstr); Oct 10, 2016 at 9:30

You must log in to answer this question.