Looks good to me. If it works and does what you need.

Or you could try something like

SELECT * FROM persons WHERE FORMATDATETIME(born, "DD MM") = FORMATDATETIME(CURRENT_DATE, "DD MM") then you could skip putting in any parameters.



On 14/01/2012 12:48 AM, the nigga wrote:
I could do what needed. I do not know if it's the best way but worked.

here how I did.

  public List<Persons>  getPersonsBirthday(){
         // return a list of all persons birthdays today
         List<Persons>  lista = new ArrayList<Persons>();
         GregorianCalendar cal = new GregorianCalendar();
         int day = cal.get(cal.DAY_OF_MONTH);
         int month = cal.get(cal.MONTH) + 1;
         try {
             PreparedStatement stm = this.con.prepareStatement("SELECT
* FROM persons WHERE DAYOFMONTH(born) = ? AND MONTH(born) = ?");
             stm.setInt(1,day);
             stm.setInt(2, month);
             ResultSet rs = stm.executeQuery();
             while(rs.next()){
                 Persons person = new Persons();
                 person.setBorn(rs.getString("born"));
                 lista.add(person);
             }
             rs.close();
             stm.close();
         } catch (SQLException ex) {

Logger.getLogger(PersonsDAO.class.getName()).log(Level.SEVERE, null,
ex);
         }
         return lista;
     }

That's worked. there another way to do that ?

thanks.


On 13 jan, 10:58, Ryan How<[email protected]>  wrote:
Do you want the date of their next birthday?

An example of the output you want would be helpful.

On 13/01/2012 12:19 PM, the nigga wrote:







Hello
I have a field in my table persons:  BORN DATE.
how can I get a birthday of a person through a SELECT ?
I am trying do this using Calendar,but not work.
thanks.

--
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to