11 Replies Latest reply on Jan 30, 2017 1:59 AM by BruceRobertson

    Automatically show current date on opening app.


      I want a field ("Today's Date") to show the current date every time I boot up my computer and open my database in FM15.

      Why should such a simple operation cause so much a problem?

      I have tried several options from specifying "Get current date" to "Get currentHostTimestamp" in various options/scripts.

      I can get the date to appear when I click the "Today's Date" field BUT the following day, it is still showing the same date!! (unless I select that field again!!)

      All I want is the field to automatically show the currect date when I open the application!!

      Maybe someone could tell me where I am going wrong please which seems to me to be a simple operation. Thanks.

        • 1. Re: Automatically show current date on opening app.

          Probably due to how you have the field set up.  You don't need to have a field for this, In layout mode just choose "insert" from the top menu and choose 'date symbol'

          • 2. Re: Automatically show current date on opening app.

            I will caution you about something I discovered the hard way. I had a field called "Current Date" which was set as a calculation with result of type Date, set = Get ( CurrentDate ), and it was used in various places thruout the system to, for example, calculate ages based on date of birth, or what semester it was, based on a known schedule of when we moved from fall to spring to summer. But it wasn't working properly.


            I finally figured out that it was because the file it was located in lived on the server, which never got turned off. So the last time that file had been opened was in April, and here it was September, and the Global calculation field still thot it was April, because there had never been any reason to change its original value.


            I ended up changing "Current Date" to just a plain Global Date field and putting a step in the "Startup" script of the main file that would set the value of "Current Date" to "Get ( CurrentDate )" every time that file was opened anew by a guest user over the network. Thus, even if the file on the server remained open for months on end, still thinking that the current date was whenever it was previously opened, each user got to see the value as of when he or she had personally opened it over the network.


            This relies on an oddity of the way Global fields work. You might assume from the name "Global" that its value is the same for everybody, but the nomenclature is misleading. It's really better to think of it as a Session field, because it has whatever value is assigned to it by a particular user during a particular log-in on a particular computer.

            • 3. Re: Automatically show current date on opening app.

              I agree with Wim's comment but it would be helpful to hear how you intend to use the date.

              If it really true that you ONLY want to see it on layouts as reminder of the date, then we're done, Wim's answer is correct.

              If you intend to use the current date in calculations or scripts or as the "left side" value in relationships, that is an entirely different matter.

              • 4. Re: Automatically show current date on opening app.

                Why reference a global field rather than use the Get(currentdate) function in a calculation?


                A global field is supposedly used only by the computer not by other computers and is more or less permanent. So if the field was set at 2 minutes to midnight then at 2 minutes after midnight it would be wrong. Or if the user moved into a new time zone then again the global would be wrong.


                Hmm, I wonder if IOS recognizes a time change by gps? Actually this is a valid question for travelers if time calculations are critical.


                Also the accuracy of the user's clock is critical. The time and date can be changed at any time. I have had Google protest when I was using a changed date during testing of a fmp file.


                Anyone have a calc for getting the time based on the current location.

                • 5. Re: Automatically show current date on opening app.

                  Thank you wimdercorte, Richard, Bruce and gofmp for your response.

                  I have done as wimdercorte suggested, so simple, when you know how, and all is great, thanks.

                  In response to Bruce’s question – I have a database of clients (“Contacts”) and sometimes I get requests for names and address etc of people I have on this data base. So I created a different Table, called “Names for Export” , linked to my main database, which would create a pdf showing name, address etc which I would then email to the person enquiring.

                  In addition I had a field on this export layout called “Date created” to which I used the following configuration: - I created a field called "Date created", type "Date" > Options > Calculated value > Specify "Current_Date=Get ( CurrentDate )".

                  NOW, after some messing around, this worked fine because every time I would send a new client’s details, the window would refresh and produce the current date.

                  Whilst I was trying to achieve this operation I went back to my main database (“Contacts”) to see if I could produce a similar date field that automatically changed when I opened up the application, which incidentally Richard, is stored on my own hard drive. I tried all of the above and more and could not get it to update when I rebooted until wimdercorte gave me the information.

                  No, I don’t really need it here but it frustrated me that I couldn’t get it to work and now I can thanks to the help in the community.

                  At least I got my export form to display the correct information.

                  • 6. Re: Automatically show current date on opening app.

                    On the one hand: I'm glad you got the PDF export to work, by placing a date symbol on the layout.


                    On the other hand: your description of your date field design indicates that you still have a bit more to learn about how fields are specified. Your statement is very very confusing. Being able to correctly specify a field is a skill that you will need to master.


                    It might be helpful if you would create and post a simple example of what you attempted.

                    Or maybe a screen shot or field-definition print-to-PDF so we can see exactly what you did.

                    Or maybe a clone of your actual file.

                    Perhaps, including some other fields as well.

                    Meanwhile, I have created a (hopefully) instructive example.


                    Edited: attachment added.

                    • 7. Re: Automatically show current date on opening app.

                      What I thought you said in your field description.

                      what I thought you said.png

                      • 8. Re: Automatically show current date on opening app.

                        Thankyou Bruce for your feedback and attachment. Just to correct you on one small point, I used the date symbol on my main Contacts layout following the suggestion from wimdercorte. In hindsight, I dont really need this in this layout but it was good to learn how to achive it.

                        In the Table, “Names for Export”, which I use for producing the pdf, I used the field description as per your screen shot and v1 or v2 in the ADateField.fmp that you also sent me. One small difference is that I used "Get currentHostTimestamp" instead of “Get Current date” as demonstrated in my screen shot. But it all works well.

                        I hope this makes sense? Thanks


                        • 9. Re: Automatically show current date on opening app.

                          No, it doesn't quite add up.

                          Your calculation again does not match your description.

                          It shows an auto-enter calc that will NOT remain current.

                          Tomorrow it will be wrong.

                          Secondly, small difference, your actual calc does not use get( CurrentHostTimeStamp).

                          It uses get( CurrentTimeStamp).


                          I don't know what your workflow is to create and export these records.

                          If it always uses newly created set of records - it will be OK.

                          But if you have an ongoing set of records, and now and then perform your export, the date field will be out of date.

                          It will be the date created for the record. Some might be new; some might have been created six months ago.

                          Again - that is accurate for the record in question.


                          But that isn't what you declared in the start of this thread. You said you always want it to show today's date.

                          • 10. Re: Automatically show current date on opening app.

                            My sole purpose for posting “Automatically show current date on opening app” was, for me, correctly answered by wimdecorte

                            Apologies Bruce if I have confused you en route. My explanation to you, which I agree had some anomalies, was an explanation of what I was doing in the process of achieving the above.

                            I only wish to export these records on odd occasions and so as you say, “it will be OK”

                            Anyway, with the help from yourself and other members of the community I have achieved what I wanted and thanks very much for that.

                            • 11. Re: Automatically show current date on opening app.

                              Though ExportDate will mostly, never actually be export date.