'SQFLITE - Get records from yesterday and previous dates | Get records for tomorrow and future dates

Note: (No need to answer) I'm writing this for my future self in case I forget and others who might need it

I'm trying to get records plotted yesterday and older and records plotted for tomorrow and the following days. The year, month, and day values for the plotted dates are separated in 3 columns (year, month, day). For example, the date for an event plotted tomorrow is stored in the db under the following columns as INTEGERS:

year - 2022
month - 1
day - 26

Here's what I have so far:

SELECT * from events 
WHERE DATE(year-month-day) < '2022-01-26'

The problem in the code above is it doesn't filter the dates. Plotted events tomorrow and other future events are being included.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source