4 Replies Latest reply on Nov 28, 2011 9:53 AM by LaRetta_1

    Update date

    UnionGuy

      Title

      Update date

      Post

      I have a date field, but it does not seem to be updating when I open my file on a different day. I am using Get(CurrentDate). Which function will update the date each time I open FMP or the date changes? Thanks.

        • 1. Re: Update date
          LaRetta_1

          What is the purpose of this date field, please?

          Most Get() functions should be set up as calculations and must be specified in 'Storage Options' as 'do not store calculation results' so it will update.  I ask the purpose here because, if this date is in a preferences file to establish 'today' and it must be indexted so it is set up as a regular date field, then you must reset the value every day when your file opens by using script similar to:

          Go to Layout [ Preferences ]
          Set Field [ date ; Get ( CurrentDate ) ]
          ... go about your normal opening routine

          So we need purpose of the date field and whether it is calculation or standard date field. :-)

          • 2. Re: Update date
            LaRetta_1

            As an aside, I use trigger field (which I update at startup) and global calcs because the Preferences values are then available throughout my solution without relationships (less clutter in the graph since I only need one Preferences table occurrence then).  Some people also load global variables with the values upon startup.

            • 3. Re: Update date
              UnionGuy

              I have an invoice file that I want the date to show the month before the current date whenever I print out the invoice, which is usually monthly. For example, if I am printing it in November, I want it to show October.

              I had it set up as a calculation field with Date(Month(Get(CurrentDate))-1, but it did not seem to be updating. I changed it to a date field with the Do Not Replace Existing Value unchecked (so it would replace existing value), but it still was showing September, when even though it is now November.

              • 4. Re: Update date
                LaRetta_1

                The field should be type calculation and not auto-enter field.  Set the storage options as I've suggested or it will not update.  If you want a date, do you want the result to be the same day as the current day?  Or do you want end of the month date of prior month?  Here are a few examples:

                Last day of prior month: 

                Get ( CurrentDate ) - Day ( Get ( CurrentDate ) )
                ... or
                Date ( Month ( Get ( CurrentDate ) ) ; 0 ; Year ( Get ( CurrentDate ) ) )

                Prior month but same day:

                Date ( Month ( Get ( CurrentDate ) ) -1 ; Day ( Get ( CurrentDate ) ) ; Year ( Get ( CurrentDate ) ) )