I'm trying to write a SQLite query in Android where I select all rows from a table where the day component of the datetime column (stored as ISO 8601 strings) equals a given day. Basically, I want to select all rows with a certain date, disregarding the time.
How can this be achieved?
Use this query
select * from table_name where day=desired_day;
So this code:
database.query("table_name", null, "day like ?",new String[]{"____-__-daynumber%"}, null, null, null, null);
Checkout this documentation to see how I figured out that sql regex to use. This regex allows for any year and any month. If you want only a specific day in a specific month in a specific year do:
database.query("table_name", null, "day like ?",new String[]{"1983-03-22%"}, null, null, null, null);
This would look for the day 03/22/1983
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With