We're taking attendance data inside a certain table mainly taking the values (userId, startDate, endDate). If an individual is applicable leave on the certain date then only startDate is filled and when he is applicable for some dates then your start/finish dates are taken. What query can help me find if an individual takes leave on the certain date (say around the ninth, twelfth, 15th of the month)

user1, 9/8/2010
user2, 9/9/2010, 9/10/2010
user3, 9/14/2010
user4, 9/15/2010
user5, 9/9/2010, 9/20/2010

users taking leaving on 9th would be user2, user5
users taking leaving on 12th would be user5
users taking leaving on 15th would be user4, user5

The query shouldn't contain database specific constructs, it must operate on h2 / mysql / postgres using hibernate because the ORM layer

SELECT  userId
FROM    mytable
WHERE   '2010-09-09' BETWEEN startDate AND COALESCE(endDate, startDate)