Menu

DateTime value within a where clause

Help
2009-01-28
2013-03-22
  • Myriam Leggieri

    Myriam Leggieri - 2009-01-28

    Hi all,
    I have to add a where clause to a SelectQuery object in which the value specified for the given DbColumn is a java.util.Date filled in with both date and time informations.

    But if I use the JdbcEscape enum value 'timestamp' to represent that Date object, it includes milliseconds which are not included neither within the values stored in the database (consequently they don't match) neither within the Date object (in a Date object is not possibile to set milliseconds).

    So how can I match values in the database stored in the format:
    day-month-year hour:min:sec

    with a where clause created with SqlBuilder
    (for example:
    WHERE date <> {d '2008-12-18 09:22:19'} 
    rather than WHERE data <> {d '2008-12-18 09:22:19:234'} using timestamp) ?

     
    • Myriam Leggieri

      Myriam Leggieri - 2009-01-28

      I've solved in this way:
      indeed of using JdbcEscape, I contruct a string composed by year-month-date hour:min:sec and I add that to the BynaryCondition method (equalTo(), etc.) as it's a common value
      so I get:
      WHERE (date <> '2008-12-18 9:22:19')

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.