Reputation: 24502
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); \\ ☝ //
Upvotes: 0
Views: 35
Reputation: 52344
With string concatenation:
strftime('%s', 'now', 'localtime', 'start of day', :period || ' days')
Upvotes: 1