Home > Net >  How to query rows by intraday time range in sqlite
How to query rows by intraday time range in sqlite

Time:04-12

I have a column that consists of the datetime for each entry in the table. The entries are across many days and across all times. I want to filter only for entries that happened between a certain time period in the day, like between 10am and 1pm. How does one do that?

The datetimes are stored as a string in ISO-8601 format. Ex: 2021-01-22T12:50:00-05:00

CodePudding user response:

First, keep the sqlite Date and Time Functions doc handy.

Something like:

WHERE strftime("%H:%M",yourdate) between "10:00" and "13:00"

should accomplish the task.

  • Related