Here is the code to display list of Account records having Name="Test". If you need to display the records based on a perticular created date, then replace 'Name' in the SOQL query with the 'Created_Date' field.
public class ListOfRecords {
public List<Account> Acclist{get;set;}
public ListOfRecords()
{
getlist();
}
public List<Account> getlist()
{
Acclist = [select id,Name from Account where Name=:'Test'];
return Acclist;
}
}
If you are trying to dynamicaly display the records, then you can use following query in your controller,
String queryStr='select id, name from Account ' +
' where name=:'givenName';
List<Account> accs=Database.query(queryStr);
'givenName' indicates the name given by the user.
Can you please Let me know if it helps or not!!!
If it helps don't forget to mark this as a best answer!!!
public class DisplayAccountBasedOnNameorDateClass {
public String Name{get;set;}
public Date CD{get;set;}
public List<Account> accountList {get;set;}
public DisplayAccountBasedOnNameorDateClass()
{
accountList=new List<Account>();
}
public void SearchMethod()
{
AccountList = [SELECT id,name,CreatedDate from Account where name like: Name or CreatedDate =: CD];
}
}
Hi, Thank you for responding. Bhargavi your code is working for searching by name but I want to get records by created date also. created date should be like calender date should come.either by entering name or created date or if both entered the corresponding records have to come. could you look into that part.
Here is the code to display list of Account records having Name="Test". If you need to display the records based on a perticular created date, then replace 'Name' in the SOQL query with the 'Created_Date' field.
Visualforce Page : Controller :
If you are trying to dynamicaly display the records, then you can use following query in your controller, 'givenName' indicates the name given by the user.
Can you please Let me know if it helps or not!!!
If it helps don't forget to mark this as a best answer!!!
Please try the below code I think this will help you:
VF Page:
Class:
Thanks
Bhargavi.
Hope this will help.
Use the below code if you want to search records based on date.
Thanks
Thank you for responding. Bhargavi your code is working for searching by name but I want to get records by created date also. created date should be like calender date should come.either by entering name or created date or if both entered the corresponding records have to come.
could you look into that part.