Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JDBI interval postgresql

How properly use such query with date intervals

 @SqlUpdate("delete fromlogin where created < now() - ':days days' :: interval")
 void deleteOldLogin(@Bind("days") Period days);
like image 630
LeshaRB Avatar asked Feb 18 '26 00:02

LeshaRB


1 Answers

You can't pass the number of days inside an interval constant as a parameter. You need to pass an integer specifying your number of days, then multiply that with an interval of the desired length.

@SqlUpdate("delete fromlogin where created < now() - :days * '1 day'::interval")

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!