Don't know about such thing, but I guess that a plpgsql function could help using datetime var's.
Just a guess, don't know if the optimal solution.
Best wishes,
G.-
--
"Adopting the position that you are smarter than an automatic
optimization algorithm is generally a good way to achieve less
performance, not more" - Tom Lane.