I'm creating a string that I an then use in a method that queries a mongodb collection. Eventually the dates will be from user input. Here's the relevant code and string:
import pymongo
from pymongo import MongoClient
from datetime import datetime
import time
import datetime
start_yr = 2015
start_mnth = 2
start_day = 1
end_yr = 2015
end_mnth = 2
end_day = 28
# this is the line called in the error
created_at_string = { "created_at": {"$gte" : datetime(start_yr, start_mnth, start_day),"$lt" : datetime(end_yr, end_mnth, end_day)}}
The idea will be to use created_at_string as an argument in more complex query methods.
I'm getting:
Traceback (most recent call last):
File "main.py", line 218, in <module>
program.runProgram()
File "main.py", line 61, in runProgram
report.RcreateReport()
File "/filepath/report.py", line 95, in RcreateReport
created_at_string = { "created_at": {"$gte" : datetime(start_yr, start_mnth, start_day),"$lt" : datetime(end_yr, end_mnth, end_day)}}
TypeError: 'module' object is not callable
Why?
from datetime import datetimeand not justimport datetime?import datetimeand tried to call the module...from datetime import datetimeand thenimport timeand thenimport datetime