Conrad Jagger
Conrad Jagger

Reputation: 91

SSIS - Get difference in minutes between two dates in Script Task

I have written script component using vb.net and using following:

        Dts.VariableDispenser.LockForWrite("User::StepStartTime")
        Dts.VariableDispenser.LockForWrite("User::StepEndTime")

Assigned value to this at Start vars("User::StepStartTime").Value = Date.Now

Assigned value to this at End vars("User::StepEndTime").Value = Date.Now

I'm struggling to find a function which can give difference in minutes between these two above dates.

Regards

Upvotes: 0

Views: 1754

Answers (1)

Bill Anton
Bill Anton

Reputation: 2970

Just subtract them...

DateTime tStart = Dts.VariableDispenser.LockForRead("User::StepStartTime");
DateTime tEnd = Dts.VariableDispenser.LockForRead("User::StepEndTime");

// Capture differnce between two datetime values
TimeSpan tSpan = tEnd.Subtract ( tStart );

// Capture tSpan in minutes
Dts.VariableDispenser.LockForWrite("User::DiffInMinutes") = tSpan.TotalMinutes;

References

http://msdn.microsoft.com/en-us/library/1905yhe2.aspx

http://msdn.microsoft.com/en-us/library/system.timespan.aspx

Upvotes: 1

Related Questions