The solution is actually quite simple: use HSQL with an algorithm to convert the dates to YYMMDD.
The following looks for contract prices where August 14, 2009 is between the MMDDYY begin and expire dates:
def query =
ContractPrice.executeQuery(
"""FROM ContractPrice cp WHERE
? BETWEEN
MOD((cp.beginDate * 10000.01), 1000000)
AND
MOD((cp.expireDate * 10000.01), 1000000)
""",
[90814],
[max:params.max.toInteger(),
offset:params.offset.toInteger(),
sort:params.sort])
The trick is an old RPG programmers trick of multiplying the MDY date by 10000.01.
Note that the query will be fairly slow as it will have to do a table scan. But what my applications normally do is use precedes the date math with a predicate on a column that performs well with the query optimizer.
chant with me "we want more posts, we want more posts" :-) Nothing since Aug 2009? Don, where are you?
ReplyDelete