Time conversion in Python3

the date format stored in MongoDB is 2018-07-01T00:00:00Z

the environmental background of the problems and what methods you have tried

related codes

collection.find_one(
    {
        "regDate": 
        {
            "$gte":ISODate("2018-07-01T00:00:00Z"),"$lt":ISODate("2018-07-31T00:00:00Z")
        }
    }
)
Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
NameError: name "ISODate" is not defined
Mar.30,2021

according to your error prompt, you can take a look at this solution

https://jira.mongodb.org/browse/PYTHON-704

ISODate is used on the mongo command line, and datetime is available in python.

from datetime import datetime

collection.find_one(
    {
        "regDate": {
            "$gte": datetime(2018, 6, 1), "$lt": datetime(2018, 7, 31)
        }
    }
)
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-1b370a0-2c066.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-1b370a0-2c066.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?