Number of day betwen once Date variable and the current date?

Eduardo Menezes (20 posts)
March 19, 2024 02:50 PM
Accepted Answer

Hello Bill

I hope you are doing great.

I have on job with two date variables "fromDate" and the current Date?

Is there a way that I can calculate the number of the days between the two dates to use in the command-Line Parameter?

Something like this: DateDiff(%fromDate% - GetDate())

I need one way to have the number of the days.

Please let me know if you need more details.

Thank you.

Bill Staff (602 posts)
March 20, 2024 02:52 PM
Accepted Answer

You can do this with an Inline Function that calculates the number of days.

Edit the InlineFunctions script library and add the following function definition to it (assuming that the library still is configured to use the default VB.NET language setting):

    'Returns the number of full or partial days elapsed since the startDate
    Public Function ElapsedDays(startDate As DateTime) As Integer
        Return Math.Floor(DateTime.Today.Subtract(startDate.Date).TotalDays)
    End Function

This can go anywhere in the module (make sure it goes before the "End Module" statement at the end.)

For the command line, use this:




Eduardo Menezes (20 posts)
March 27, 2024 01:57 AM
Accepted Answer

Hello Bill,


Thank for your support as always.

The function works great, but I noticed that sometimes it gives an error to randon steps that are using the function.


Inline function evaluation failed for "ElapsedDays(date_from)": [ADT005098E] 


Have you seen this error or suggest any way that I can fix it?

Eduardo Menezes (20 posts)
March 27, 2024 01:58 AM
Accepted Answer
Eduardo Menezes (20 posts)
March 27, 2024 02:01 AM
Accepted Answer