SSIS Script Task implicit conversion from 'Object' to 'Date'

I get the error above on the User::GV_SYNCHTIME in the DateAdd function
It is in the Read/Write Variables and is set as DateTime. What is the issue please......

Public Sub Main()
        '
        Dim SynchTime As Date = DateAdd(DateInterval.Second, -10, Dts.Variables("User::GV_SYNCHTIME").Value)
        Dts.Variables("User::GV_SYNCHTIME_TEN").Value = SynchTime
        Dts.TaskResult = ScriptResults.Success
        '
    End Sub
dkochenoAsked:
Who is Participating?
 
nishant joshiTechnology Development ConsultantCommented:
Please try below to pass datetime type to Dateadd function.

Public Sub Main()
        '
        Dim SynchTime As Date = DateAdd(DateInterval.Second, -10, Convert.ToDateTime(Dts.Variables("User::GV_SYNCHTIME").Value))
        Dts.Variables("User::GV_SYNCHTIME_TEN").Value = SynchTime
        Dts.TaskResult = ScriptResults.Success
        '
    End Sub

Open in new window

0
 
dkochenoAuthor Commented:
Perfect - Thank you - it was driving me nuts :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.