Hi,
When I add the following import statement to my jython library (outside of a function):
from datetime import datetime, timedelta
today() starts returning the error
Why is that? It seems okay to use the import within a function definition, so that is what I am going to do.
Joleen
from datetime import causes error with today() function
Re: from datetime import causes error with today() function
I did get an answer for why this might be happening.
The today() function is probably importing the datetime module as "import datetime" setting the reference to the module.
When I use from datetime import datetime, I am setting the reference to the datetime class and get the error. If I would use any of the following
import datetime
from datetime import datetime as dt
or from within a specific function "from datetime import datetime"
I do not have a problem with the today() function.
Joleen
The today() function is probably importing the datetime module as "import datetime" setting the reference to the module.
When I use from datetime import datetime, I am setting the reference to the datetime class and get the error. If I would use any of the following
import datetime
from datetime import datetime as dt
or from within a specific function "from datetime import datetime"
I do not have a problem with the today() function.
Joleen