I'm using Room library in an android project. How can I use the method parameter in strftime() function (something like :period days
instead of 7 days
)?
@Query("SELECT * FROM purchase " +
"WHERE date >= strftime('%s', 'now', 'localtime', 'start of day', '7 days')")
List<Purchase> getPurchases(int period); \\ ☝ //
With string concatenation:
strftime('%s', 'now', 'localtime', 'start of day', :period || ' days')