Select only time from datetime field in SQLite

In my table, I have a datetime field that stores dates in this format:

YYYY/mm/dd HH:MM:SS 

Now I need to get through the request only time.

I tried this

 SELECT time(start_date) FROM table LIMIT 100 

but no luck, it gives me "no error", but no records are returned

Any idea?

EDIT

I solved it! The problem is that SQLite requires Times to be in a format in which, if hours, minutes and seconds are less than 10, they must be represented by zero.

For example:

  H:M:S WRONG --> 12:1:30 RIGHT --> 12:01:30 

Moreover, the correct format for dates is YYYY-mm-dd, not YYYY / mm / dd.

+7
source share
1 answer

SQLite has a built-in function called strftime (format, datetime) that can be used to retrieve any required information from a given time. In your case, you can use like this:

 SELECT strftime('%H:%M:%S',start_date) FROM table LIMIT 100; 
+6
source

All Articles