cancel
Showing results for 
Search instead for 
Did you mean: 

All Python Function is not working in Script task

dippradhan
New Contributor

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 ?

1 REPLY 1

akidave
Employee
Employee

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