Do you need to get the current time in SQL? Can you not move the logic
into Ruby where it is easier to test? Of course sometimes it needs to
be in SQL for performance reasons, but often this is just premature
optimization.

Perhaps you could share the actual code and SQL with us...?

-- 
James.
http://blog.floehopper.org