Django queries time questions across the wee hours of the morning, such as: from 16:00 to 5 a.m., how do you query?

The

data is imported from dbf, and the current field is the string year, month, day, hour, second, 201810110950.
what should I do across the query time in the wee hours of the morning? For example: from 16:00 in the afternoon to 5 o"clock in the morning, how to inquire? I am now independent of
hours and seconds, and the field is still a string. Do I need to adjust it to something else? Thank you

Sep.04,2021

if it is a string, you can query it. You can use a six-digit string to represent the time
between 16:00 and 5: 00 a.m., that is, 160000-235959 or 000000-050000
, that is, string comparison time_str > '160000' or time_str <' 050000'
so that all the data for this period


is selected.

Why should it be saved as a string? If you save it directly into datetime, you won't have this problem.

python tutorial


it is most convenient to store datetime for time fields. Take a look at the summary of this Django QuerySet: various uses of Django model select

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b43061-2c64f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b43061-2c64f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?