-1

I want to make a query to get records between specified hours. For example, i want to get all records between 00:00 and 01:00 for all days. So, the date does not matter but hours. How to do that?

I have done this, but it only return for certain dates.

Select name from my_table where date_column> beginning and date_column< end

Here beginning and end are in millisecond. Also my date_column is stored in millisecond format.

Brian
  • 3,850
  • 3
  • 21
  • 37
Co Koder
  • 2,021
  • 7
  • 31
  • 39

1 Answers1

4

Use strftime():

Select name
from my_table
where strftime('%H', date_column) = '00';

This just checks the hour. You could use '%H:%M:%S' if you wanted more granularity.

EDIT:

You do not have a date time value. You have something else. It looks like a Unix epoch time measured in milliseconds rather than seconds. If so, the following should work:

Select name, datetime(date_column/1000, 'unixepoch')
from my_table
where strftime('%H', datetime(date_column/1000, 'unixepoch')) = '19';

However, none of the times are at hour 3. You may need to convert using your localtime.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786