8 Replies Latest reply on Oct 11, 2013 3:09 PM by philmodjunk

    Date Function

    dg3321

      Title

      Date Function

      Post

           If i have an invoice dated 1/1/13, and i want to have a certain location on the invoice to say "Bill due by 2/1/13"...how do i write the date function so fmp knows to take the invoice date and add 1 month to it?

        • 1. Re: Date Function
          philmodjunk

               Date ( Month ( YourDatefield ) + 1 ; Day ( YourDateField ) ; Year ( YourDateField ) )

               You may want to specify a specific day in this calculation instead of copying the day from the original date field. If the day is close to the end of the month such as a day that is 29, 30 or 31, then this function may return a date that is the first, second or third day two months in the future.

          • 2. Re: Date Function
            dg3321

                 That worked, thanks!

                 To take this one step further.  Sometimes, I grant an extension for a payment due.  I don't know if this is possible since i already have a date function in the 'Bill Due By' field'.  Is it possible to script a button that would override the above mentioned date function and then add on an additional month to the 'Bill Due By' field?

            • 3. Re: Date Function
              dg3321

                   I actually figured it out using 'replace field contents.

              • 4. Re: Date Function
                philmodjunk
                     

                          I actually figured it out using 'replace field contents.

                     Since that will modify every record in your found set and cannot be reversed if you make the wrong change or change the wrong records, that sounds like a rather dangerous way to do this.

                • 5. Re: Date Function
                  dg3321

                       Understood.  What would you recommend?

                  • 6. Re: Date Function
                    philmodjunk

                         You'll need to describe in more detail what you are trying to do. It's not clear to me what changes need to be made and in what fields/records when you "grant an extension for a payment due". Are you modifying the date due for a single record or a group of records?

                    • 7. Re: Date Function
                      dg3321

                           I have a field that shows the current date when an invoice is created.  I then have a separate field that shows that invoice date + 1 month which is the 'payment due' field.  i sometimes grant an extension for payments by 1 month.  So i would like to script a button to add an additional month onto the 'payment due field'.  

                           i experimented with the 'replace field contents' idea but had the problem that you said would happen; multiple records changed when i did this as opposed to the one record that i wanted to change.

                           I'm modifying the date due for a single record.

                           Thanks!

                      • 8. Re: Date Function
                        philmodjunk

                             Set FIeld can be used to modify a field in the current record.

                             You could also just set up a number field named "Extension" with a single value check box that sets a 1 in the field when clicked. (You can resize the field so that the 1 is not visible, just the checkbox.) Then you can modify the original calculation to add 2 to the month field instead of 1 if this field is set to 1. That accomplishes the same result but with no scripting required.