09-17-2017 07:42 AM
I have perfectly executed python code in my computer. However, same code does not execute in Script task. For instance, I used parse() function to format datetime. parse(“2017-08-27T00:00:00.000”).date() works in my computer, but not in script task.
Although I imported (from datetime import date, time,datetime) required libraries in the script task.
Error I received “global name ‘parse’ is not defined”
from datetime import date, time,datetime
from dateutil import relativedelta, parser
INCR_LOAD_START_TIME = “2017-08-27T00:00:00.000”
V_PROCESS_START_DATE =parse(INCR_LOAD_START_TIME).date()
print(V_PROCESS_START_DATE)
Could you please help on how do I import dateutil into Snaplogic ?
09-18-2017 01:28 PM
dateutil is not part of the python standard library, so it cannot be called from the Script.
Do something like
from datetime import datetime
INCR_LOAD_START_TIME = "2017-08-27T00:00:00"
start = datetime.strptime(INCR_LOAD_START_TIME, "%Y-%m-%dT%H:%M:%S")
Look at python - string to datetime with fractional seconds, on Google App Engine - Stack Overflow if you want to handle the milliseconds