1 Reply Latest reply on Nov 8, 2012 12:44 PM by philmodjunk

    Setting Date ranges

    Kirk_1

      Title

      Setting Date ranges

      Post

           Im doing a script to create an aged AR report. Im trying to set a date rage... that if the posted date is equal to that it will set the invoice amount into that field.

           The result of this script is that the  less than 20 day = to total AR and the greater than 121 has 90% of the invoice total.

           How can i script it to get the results i need?

            

             
      •           Go to Layout [ “Aged AR” (Invoice) ]
      •      
      •           Enter Find Mode [ ]
      •      
      •           Set Field [ Invoice::IN_Unpaid; "1" ]
      •      
      •           Set Field [ Invoice::INPosted; "yes" ]
      •      
      •           Perform Find [ ]
      •      
      •           Sort Records [ Specified Sort Order: Invoice::INCustomerName; ascending Invoice::IN__PKFlgsiProNumber; ascending ] [ Restore; No dialog ]
      •      
      •           Go to Record/Request/Page [ First ]
      •      
      •           Loop
      •      
      •           // If [ Let ( [ ~num = GetAsDate ( Invoice::INPostedDate ) ] ; ~num ≤ 20 ) ]
      •      
      •           If [ Let ( [ ~num = GetAsDate ( Invoice::INPostedDate ) ] ; ~num ≥ GetAsDate ( Invoice::INPostedDate ) and ~num ≤ GetAsDate ( Invoice::INPostedDate )+ 20 ) ]
      •      
      •           Set Field [ Invoice::INAged020days; Invoice::INRemaining ]
      •      
      •           End If
      •      
      •           If [ Let ( [ ~num = GetAsDate ( Invoice::INPostedDate ) ] ; ~num ≥ GetAsDate ( Invoice::INPostedDate ) +21 and ~num ≤ GetAsDate ( Invoice::INPostedDate )+ 32 ) ]
      •      
      •           Set Field [ Invoice::INAged2132days; Invoice::INRemaining ]
      •      
      •           End If
      •      
      •           If [ Let ( [ ~num = GetAsDate ( Invoice::INPostedDate ) ] ; ~num ≥ GetAsDate ( Invoice::INPostedDate ) +33 and ~num ≤ GetAsDate ( Invoice::INPostedDate )+ 59 ) ]
      •      
      •           Set Field [ Invoice::INAged3359days; Invoice::INRemaining ]
      •      
      •           End If
      •      
      •           If [ Let ( [ ~num = GetAsDate ( Invoice::INPostedDate ) ] ; ~num ≥ GetAsDate ( Invoice::INPostedDate ) +60 and ~num ≤ GetAsDate ( Invoice::INPostedDate )+ 90 ) ]
      •      
      •           Set Field [ Invoice::INAged6090days; Invoice::INRemaining ]
      •      
      •           End If
      •      
      •           If [ Let ( [ ~num = GetAsDate ( Invoice::INPostedDate ) ] ; ~num ≥ GetAsDate ( Invoice::INPostedDate ) + 91 and ~num ≤ GetAsDate ( Invoice::INPostedDate )+ 120 ) ]
      •      
      •           Set Field [ Invoice::INAged91120days; Invoice::INRemaining ]
      •      
      •           End If
      •      
      •           If [ Let ( [ ~num = GetAsDate ( Invoice::INPostedDate ) ] ; ~num ≥ GetAsDate ( Invoice::INPostedDate ) +121 ) ]
      •      
      •           Set Field [ Invoice::INAged121days; Invoice::INRemaining ]
      •      
      •           End If
      •      
      •           Go to Record/Request/Page [ Next; Exit after last ]
      •      
      •           End Loop

        • 1. Re: Setting Date ranges
          philmodjunk

               I think you need to use Get ( currentDate ) here.

               Take a look at this part of your calculations:

               Let ( [ ~num = GetAsDate ( Invoice::INPostedDate ) ] ; ~num ≥ GetAsDate ( Invoice::INPostedDate )...

               You are comparing the date in Invoice::INPostedDate to the date in Invoice::INPostedDate.

               Naturally, the result is that the dates are equal.

               I think you want something more like this here:

                Invoice::INPostedDate ≥ Get ( CurrentDate ) and Invoice::INPostedDate ≤ Get ( CurrentDate ) + 20