7 Replies Latest reply on Apr 26, 2011 12:00 PM by projay

    Find Last months sales

    projay

      Title

      Find Last months sales

      Post

      I am trying to create a script to quickly view Last Months Sales...instead of having to type in or select dates.

      Is their a short cut to that....I know for todays date is //...so is there anything for previous month

      Thanks

      -Jay

        • 1. Re: Find Last months sales
          LaRetta_1

          There are many calculations you can use.  Here is one calculation and its script:

          Go to Layout [ layout with the sales ]
          Enter Find Mode [ uncheck pause ]
          Set Field [ yourDate ;with following calculation

          Let (
          prior = Get ( CurrentDate ) - Day ( Get ( CurrentDate ) )
          ;
          Month ( prior ) & "/" & Year ( prior )
          )

          Set Error Capture [ On ]
          Perform Find [ ]
          If [ not Get ( FoundCount ) ]
          Show Custom Dialog [ "No sales last month." ]
          Go to Layout [ original layout ]
          Exit Script [ ]
          End If
          .... continue script with whatever you wish if records found.

          • 2. Re: Find Last months sales
            projay

            Hi and thanks, That worked great...I take it that to do something like that for the Current Week (this weeks sales) seems a bit more challenging...any suggestions on that?

            Thanks

            -Jay

            • 3. Re: Find Last months sales
              LaRetta_1

              I would have to make an assumption that you want Sunday through Saturday always of the prior week.  If so, one way of writing the calculation for your search on the date would be range:

              Let (  [
              now = Get ( CurrentDate ) ;
              end =    now  - DayOfWeek ( now )   ;
              start = end - 6
              ] ;
              start & ".." & end
              )

              Note that I am not using WeekOfYear() are there is reason.  If you are going backwards and you cross the year boundary from January back to December, it would break because the WeekOfYear() numbering starts over. 

              • 4. Re: Find Last months sales
                projay

                Hi I tried the script and works great...but it gets the sales from LAST week...what adjustments can I make for this week?

                -Jay, thanks for your help.

                • 5. Re: Find Last months sales
                  LaRetta_1

                  Not sure where I got that you wanted the prior week.   Laughing

                  I suppose it  was because, if the day is Monday then they won't have a full week to  find or it was because you had asked for last months sales prior.  Anyway, my apology for misunderstanding.  You can change the find calculation to:

                  Let (
                  start = Get ( CurrentDate ) - DayOfWeek ( Get ( CurrentDate ) ) + 1 ;
                  start & ".." & Get ( CurrentDate )
                  )

                  • 6. Re: Find Last months sales
                    LaRetta_1

                    Wait.  Can a sale be later than the current date?  Do you ever post-date sales?  If so then change to:

                    Let (
                    start = Get ( CurrentDate ) - DayOfWeek ( Get ( CurrentDate ) ) + 1 ;
                    start & ".." & start + 6
                    )

                    • 7. Re: Find Last months sales
                      projay

                      GREAT!! that worked!

                      Thanks

                      -Jay