SSRS - Number of days between 2 dates.

  • I am trying to display in my report the number of days between Purchase_Date and Booking_Date.

    I have written a Function in the Custom Code of the report as;

    Function DispTypeString(value1 AS DateTime, value2 AS DateTime) As Long

    Dim NumberOfDays AS Long

    NumberOfDays = Datediff("d","Purchase_Date","Booking_Date")

    Return NumberOfDays

    End Function

    The return fields' expression is:

    =Code.DispTypeString(Fields!Purchase_Date.Value,

    Fields!Booking_Date.Value)

    I have been working on this problem for far too long and really need some expert help.

    Bill

  • Can you not use the datediff function as a part of your extraction query?

  • Are you getting errors in the function. The code should be something like...

    Function DispTypeString(value1 AS DateTime, value2 AS DateTime) As Long

    Dim NumberOfDays AS Long

    NumberOfDays = Datediff("d",value1,value2)

    Return NumberOfDays

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply