[SOLVED] Using date parameters in postgres native queries

Imagine that I want to spot check a particular table during a particular hour.

I’d like to do something like
WHERE
created >= {{date}} AND
created < {{date}} + ‘1 hour’::interval

But of course, the second clause doesn’t work because postgres doesn’t want to add an interval to whatever the date time is returning.

If I were to replace {{date}} with timestamp '2018-12-15', adding an interval would work nicely. How do I adapt the output of {{date}} in order to add an interval?

(Once we can add intervals, I’d of course add a second interval with an hour parameter that makes it possible to start at any hour of the day.)

1 Like

Hi @dhbradshaw,

What about surrounding your {{date}} variable with the date() function ?

Best regards,
Fabrice Etanchaud
CERFrance PCH

1 Like

That does the trick. Thank you!