locked
Difference between two datetime parameters.. RRS feed

  • Question

  •  

    Hi ,

     

       Iam using sqlserver reporting services 2005 and  in one case I need to find out the difference between two datetime parameters. I need the difference with the time. Can you please help me in this.... 

     

      Thanks in advance...

     

     

    Tuesday, November 20, 2007 10:09 PM

Answers

  • Hi Ramesh,

     

    Does the difference between two datetime parameters which you have mentioned mean the number of time intervals between two Date values?  If so, let’s go on.

     

    Report Services provides DateDiff function to specify the number of time intervals between two Date values. Please try the expression as follows:

     

    =DateDiff (DateInterval.Day, Parameters! Parameter1.Value, Parameters! Parameter2.Value)

     

    This expression returns the day intervals between parameter1 and parameter2. The Interval argument can provide one of the settings, such as “DateIntervalDay”, “DateInterValWeekDay, “DateInterValYear” and so on.

     

    For more information about DateDiff function, see here:

    http://msdn2.microsoft.com/en-us/library/t83eh0x7(vs.80).aspx

     

    If I misunderstood your concern, please feel free to let me know.

     

    Thanks.

    Thursday, November 22, 2007 1:19 PM

All replies

  •  

    Hi,

     

    I am not sure if there is an easy way to do this. There is a datediff function in T-SQL. The function helps to get the difference between two dates in terms of number of days, hours,minutes,seconds etc. If we get the difference between the dates in terms of seconds, then we can apply some logic to get it in HH:MITongue TiedS format. The syntax for DATEDIFF is

     

    SELECT DATEDIFF(second,'Nov 20 2007 08:45:44', getdate())

     

    Hope this helps.

     

    Thanks,

    Akalya.

    Wednesday, November 21, 2007 4:46 AM
  • Hi Ramesh,

     

    Does the difference between two datetime parameters which you have mentioned mean the number of time intervals between two Date values?  If so, let’s go on.

     

    Report Services provides DateDiff function to specify the number of time intervals between two Date values. Please try the expression as follows:

     

    =DateDiff (DateInterval.Day, Parameters! Parameter1.Value, Parameters! Parameter2.Value)

     

    This expression returns the day intervals between parameter1 and parameter2. The Interval argument can provide one of the settings, such as “DateIntervalDay”, “DateInterValWeekDay, “DateInterValYear” and so on.

     

    For more information about DateDiff function, see here:

    http://msdn2.microsoft.com/en-us/library/t83eh0x7(vs.80).aspx

     

    If I misunderstood your concern, please feel free to let me know.

     

    Thanks.

    Thursday, November 22, 2007 1:19 PM
  • Is there a way to calculate only workdays and exclude weekends?

    Wednesday, January 16, 2008 3:34 AM
  • networkdays() in excel

    Love the Love that Loves the Love and Hate the Love that Loves the Hate.

    • Proposed as answer by Repath Athyala Tuesday, November 13, 2012 3:40 PM
    Tuesday, November 13, 2012 3:40 PM