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
Yuta FurusawaYuta Furusawa 

search record by date

Hello, I just started to learn Visual Force and I'm making Employee search and delete for my practice.

I started to make a search section first, which are Name, Birthday, and Email section however search results only works Name and Email.

How can I solve this issue?

This is my Page
<apex:page controller="EmployeeDelete2Controller">
    <apex:form >
        <apex:pageBlock title="EmployeeDelete">
            <apex:pageBlockSection columns="1">
                <apex:inputField required = "false" value="{!info.Employee_Name__c}"/>
                <apex:inputField required = "false" value="{!info.Employee_DOB__c}"/>
                <apex:inputField required = "false" value="{!info.Employee_Mailaddress__c}"/>  
            </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!search}" value="Search"/>
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!results}" var="in">
            	<apex:column value="{!in.Employee_Name__c}"/>
                <apex:column value="{!in.Employee_DOB__c}"/>
                <apex:column value="{!in.Employee_Mailaddress__c}"/>
            </apex:pageBlockTable>            
        </apex:pageBlock>
    </apex:form>
</apex:page>

This is my Controller
 
public class EmployeeDelete2Controller {
    public Employee_Management__c info { get;set; }
    
    public List<Employee_Management__c> results { get;set; }
    
    public EmployeeDelete2Controller(){
        results = new List<Employee_Management__c>();
        info = new Employee_Management__c();
    }
        
    public PageReference search(){
        String strSoqlQuery1;
        string strEmployeeNamec;
        
        String strSoqlQuery2;
        Date strEmployeeDOBc;
        
        String strSoqlQuery3;
        string strEmployeeMailaddressc;

        IF (!String.IsBlank(info.Employee_Name__c)) {
            strEmployeeNamec = info.Employee_Name__c;
            strSoqlQuery1 = 'SELECT Employee_Name__c, Employee_Mailaddress__c, Employee_DOB__c  FROM Employee_Management__c where Id != null and Employee_Name__c = \'' + strEmployeeNamec + '\'';
            results = database.query(strSoqlQuery1);
        }
                
        else if (!String.IsBlank(info.Employee_Mailaddress__c)) {
            strEmployeeMailaddressc = info.Employee_Mailaddress__c;
            strSoqlQuery3 = 'SELECT Employee_Name__c, Employee_Mailaddress__c, Employee_DOB__c  FROM Employee_Management__c where Id != null and Employee_Mailaddress__c = \'' + strEmployeeMailaddressc + '\'';
            results = database.query(strSoqlQuery3);
        }
        
        ELSE IF (info.Employee_DOB__c == null) {          
              Date myDate = date.newInstance(2020, 12, 7);
              strEmployeeDOBc = info.Employee_DOB__c;
              strSoqlQuery2 = 'SELECT Employee_Name__c, Employee_Mailaddress__c, Employee_DOB__c  FROM Employee_Management__c WHERE Employee_DOB__c <= '+ String.valueOf(myDate);
              results = database.query(strSoqlQuery2);

        }

           
        return null;
    }
}


I'm so sorry that my English skill is very poor.
Best Answer chosen by Yuta Furusawa
ShirishaShirisha (Salesforce Developers) 
Hi Yuta,

Greetings!

Please refer the sample code to search the record by Date.

https://developer.salesforce.com/forums/?id=906F0000000DBF2IAO

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri

All Answers

ShirishaShirisha (Salesforce Developers) 
Hi Yuta,

Greetings!

Please refer the sample code to search the record by Date.

https://developer.salesforce.com/forums/?id=906F0000000DBF2IAO

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
This was selected as the best answer
Kiran SamiletiKiran Samileti
Very nice also check (https://aveebaba.com/templates/avee-player/) if for JSON templates for avee music player templates
Yuta FurusawaYuta Furusawa
Thanks Shirisha  and Kiran Samileti, I just solve my problem!