5 Replies Latest reply on Mar 23, 2016 12:21 AM by keywords

    Calcualte # of days.

    Kirk_1

      My calculation does not evaluate. I'm assuming its because of the time stamp.

       

      The second one is only a date and nothing else... 3/22/2016...

       

      What is the easiest way to get it to work?

        • 1. Re: Calcualte # of days.
          BillisSaved

          Good afternoon Kirk_1,

           

          I hope your day is going well. Could you try something like this:

           

          Let ([

           

            $Date = Date ( 2; 1; 2016);

            $TimeStamp = getAsDate (Get (CurrentTimeStamp))

           

            ];

           

            $TimeStamp - $Date

           

          )

           

          You would have to substitute the values for the variables I used with you own. I think the main thing is to use the GetAsDate() function to retrieve the timestamp value prior to performing the mathematical operation. Hope this helps.

           

          God bless,

           

           

          Bill

          • 2. Re: Calcualte # of days.
            beverly

            or just GetAsDate(PaymentReceived::PMT_posted) - GetAsDate(Invoice::INDateReady)

             

            beverly

            • 3. Re: Calcualte # of days.
              Extensitech

              BizPraxis wrote:

                $TimeStamp = getAsDate (Get (CurrentTimeStamp))

               

              This'll work, so my comments are possibly nitpicky, but:

               

              Why not just Get ( CurrentDate )? (I often use getAsDate (Get (CurrenthostTimeStamp)), in case the user's clock is wrong, but wouldn't get ( currentdate ) get you the same result here?

               

              Also, I'd recommend caution using $ variables in let statements. They could overwrite local variables in running scripts.

               

              Just my 2 cents, if that.

               

              Chris Cain

              Extensitech

              • 4. Re: Calcualte # of days.
                dtcgnet

                Extensitech wrote:

                 

                BizPraxis wrote:

                  $TimeStamp = getAsDate (Get (CurrentTimeStamp))

                 

                This'll work, so my comments are possibly nitpicky, but:

                 

                Why not just Get ( CurrentDate )? (I often use getAsDate (Get (CurrenthostTimeStamp)), in case the user's clock is wrong, but wouldn't get ( currentdate ) get you the same result here?

                 

                Also, I'd recommend caution using $ variables in let statements. They could overwrite local variables in running scripts.

                 

                Just my 2 cents, if that.

                 

                Chris Cain

                Extensitech

                Excellent points on the Get ( CurrentDate ) and the caution on using "$" at the beginning of variables in let statements.

                 

                I have a question though...What result are you actually looking for? Are you looking for March 9, minus March 7, = March 5? Or are you hoping to know the number of days between date 1 and date 2? One result is a date. One result is a number. Which are you truly after? Number of days it took to process something?

                 

                The distinction is important. If you want to know what date it was 7 days prior to the current date, then you could use:

                Get ( CurrentDate ) - 7

                The result would be the DATE.

                 

                But if you want to know how many days passed between the CurrentDate and the date posted, you'd use:

                Get ( CurrentDate ) - DatePosted

                The result would be the number of days.

                 

                So...are you looking for a date or number of days?

                • 5. Re: Calcualte # of days.
                  keywords

                  Extensitech wrote:

                  Also, I'd recommend caution using $ variables in let statements. They could overwrite local variables in running scripts.

                  I totally agree, The rule I follow is to only name these calculation variables (i.e. the ones defined within a Let calc) with a $ or $$ sign if I intend them to be used beyond the statement itself. Otherwise I just name them with text only.