2 Replies Latest reply on Oct 11, 2014 9:37 AM by Ryan Thornton

    DATEDIFF showing purchases from the last 30, 60, and 90 days

    Ryan Thornton

      Looking to some up sales on a group o items for particular time frames. I was able to find out how to do YTD sales. This is currently what I'm using.

       

      IF [Time Of Order] <=TODAY() AND DATEDIFF('year',[Time Of Order],Today())= 0 THEN [Line Total] END

        • 1. Re: DATEDIFF showing purchases from the last 30, 60, and 90 days
          Johan De Groot

          Hi,

           

          you're definitely on the right track.

           

          You can just use:

           

          IF [Time Of Order] < TODAY() AND DATEDIFF('day',[Time Of Order] ,TODAY()) < 30 THEN [Line Total] END

           

          for a field 'last 30 days. Duplicate this field twice to get the 'last 60 days' and 'last 90 days' sales:

           

          IF [Time Of Order] < TODAY() AND DATEDIFF('day',[Time Of Order] ,TODAY()) < 60 THEN [Line Total] END

          and

          IF [Time Of Order] < TODAY() AND DATEDIFF('day',[Time Of Order] ,TODAY()) < 60 THEN [Line Total] END


          You can als use sets to use a filter, which can be 're-used' for other metrics:


          DATEDIFF('day',[Time Of Order],TODAY())>0 AND DATEDIFF('day',[Time Of Order],TODAY())<30

           

          DATEDIFF('day',[Time Of Order],TODAY())>0 AND DATEDIFF('day',[Time Of Order],TODAY())<60

           

          DATEDIFF('day',[Time Of Order],TODAY())>0 AND DATEDIFF('day',[Time Of Order],TODAY())<90


           

          Is this what you were looking for?