1

This is my mysql table i want list the users whose birthday is today in my jsp page.... and this my mysql table id name dob 123 ram 17/03/1993 456 jhon 30/05/1850 986 michel 06/05/1780

please help me out.....

this is my jsp file

<html>
<table>
        <tr>
             <th>id</th>
             <th>Name</th>
             <th>Date Of Birth</th>
    </tr>
<%  
      try
        {
          String query="SELECT *, TIMESTAMPDIFF(YEAR, MIN(DOB), CURRENT_DATE) from Employee";
          Class.forName("com.mysql.jdbc.Driver");
          Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","pass123");
          Statement stmt=con.createStatement();
          ResultSet rs=stmt.executeQuery(query);
             while(rs.next())
                {
                    %>
                    <tr> 
                        <td><%=rs.getString(1)%></td> 
                        <td><%=rs.getString(2)%></td> 
                        <td><%=rs.getString(3)%></td> 
                    </tr>
                    <%
                }
                    %>
</table>
        <%
         rs.close();
         stmt.close();
         con.close();
        }
         catch(Exception e)
           {
            e.printStackTrace();
           }
        %>
   </html>
Sunil C K
  • 116
  • 5

1 Answers1

1
 this may help you.....     
         replace your query with following 
        String query="SELECT *FROM Employee WHERE MONTH(DOB) = MONTH(NOW()) AND DAY(DOB) = DAY(NOW());";
Dileep Kumar
  • 510
  • 1
  • 4
  • 19