I'm currently creating a search functionality for my page. The data will be coming from DB.
In the HTML, the date is displayed in this format dd/mm/yyyy. What I want to do is, in the select query, I want to select the all columns and the date should be displayed using that format and I have a a couple of like conditions that will be used to check if there is a match.
How will I select all column, format date and at the same time check for all matches using one single statement in criteria?
Here's what I've done so far, but this wrong.
searchString = searchString.toLowerCase()
def employeeSearchCri = Employee.createCriteria();
def searchedEmployeeList = employeeSearchCri.list(){
or {
ilike("employeeNo", "%" + searchString + "%")
ilike("firstName", "%" + searchString + "%")
ilike("lastName", "%" + searchString + "%")
ilike("middleName", "%" + searchString + "%")
ilike("jobPosition", "%" + searchString + "%")
ilike("date_format(hireDate, '%d/%m/%Y' )", "%" + searchString + "%")
ilike("status", "%" + searchString + "%")
}
and{
eq("companyId",companyId)
}
}
return searchedEmployeeList;