Answered DATEDIFF calculation

  • Monday, April 30, 2012 11:34 AM
     
     

    Hi,

    how can i calculated avg in report services SSRS with two parameters (@fromdate , @todate)

    plz i need your help

    thanks;

All Replies

  • Monday, April 30, 2012 11:37 AM
    Moderator
     
     

    Hi there

    can you please explain further what kind of avg you are trying to achieve.

    many thanks

    syed

  • Monday, April 30, 2012 12:18 PM
     
     

     i want to  calculate   SUM( QTE) / (@todate  -  @fromdate)

    exemple:

    todate 2009/05/02  and   fromdate 2009/04/03

    and QTE is a measure

    thk

  • Monday, April 30, 2012 12:38 PM
    Moderator
     
     Answered Has Code

    hi there

    please use this expression in your report

    many thanks

    syed

    =Sum(Fields!RejectQty.Value)/DateDiff("d",Parameters!date2.Value,Parameters!date.Value)

  • Tuesday, May 01, 2012 9:37 AM
     
     
    Hi Syed ,



    thank you for your reply but i want a avg for each row of measure . In other terme , i want
    for exemple : Reject Qty

    10/DateDiff("d",Parameters!date2.Value,Parameters!date.Value)
    16/DateDiff("d",Parameters!date2.Value,Parameters!date.Value)
    8/DateDiff("d",Parameters!date2.Value,Parameters!date.Value)
    8/DateDiff("d",Parameters!date2.Value,Parameters!date.Value)
    90/DateDiff("d",Parameters!date2.Value,Parameters!date.Value)
    190/DateDiff("d",Parameters!date2.Value,Parameters!date.Value)

    these measures will be saved in other colomn


    in my case i will have QTE COM
     
    [URL=http://imageshack.us/photo/my-images/171/capturezf.png/][IMG]http://img171.imageshack.us/img171/3421/capturezf.png[/IMG][/URL]

    Uploaded with [URL=http://imageshack.us]ImageShack.us[/URL]
    • Marked As Answer by mabrouko Tuesday, May 01, 2012 1:54 PM
    • Unmarked As Answer by mabrouko Tuesday, May 01, 2012 1:55 PM
    •  
  • Tuesday, May 01, 2012 10:06 AM
    Moderator
     
     Answered Has Code

    Hi There

    Create a new column next to your measure and please put the formula in the column.

    I have attached a screenshot for that

    Many thanks

    Syed Qazafi Anjum

    Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful.

    =Sum(Fields!RejectQty.Value) / DateDiff("d", Parameters!date2.Value, Parameters!date.Value)

  • Tuesday, May 01, 2012 11:38 AM
     
     

    Hi  Syed,

    whene i try to execute , i have this response :<< Les restrictions imposées par l'indicateur CONSTRAINED dans la fonction STRTOMEMBER n'ont pas été respectées.>>

    thanks

  • Tuesday, May 01, 2012 11:58 AM
     
     

     hi Syed,     how did you configured the parameters date2 and date ?

     thanks

  • Tuesday, May 01, 2012 1:54 PM
     
     

    HI Seyd,

    how can i recover only date from << Parameters!FromDMDATEDATEJR.value >> in SSRS becauce i can not applicate datediff on it

    In My case i have : 

    Parameters!FromDMDATEDATEJR.value =[DM_DATE].[DATE-DAY].&[2005-03-03]

      please help

             thanks
  • Tuesday, May 01, 2012 10:01 PM
    Moderator
     
     Answered Has Code

    Hi There

    Please use this expression. I hope this will resolve your problem

    =formatdatetime(cdate("2005-03-03"),dateformat.ShortDate)
    so you can put something like this
    =formatdatetime(cdate(Parameters!FromDMDATEDATEJR.value ),dateformat.ShortDate)