9 Replies Latest reply on Mar 12, 2017 9:43 AM by siplus

    Problem with Get ( CurrentDate )


      I make calculation with Get ( CurrentDate ). But the result is a number not date !!!

        • 1. Re: Problem with Get ( CurrentDate )

          You simply need to change the calculation result to be a date.



          1 of 1 people found this helpful
          • 2. Re: Problem with Get ( CurrentDate )

            Thank you very much !!!

            • 3. Re: Problem with Get ( CurrentDate )

              And if you do not click storage options to make this an unstored calculation, you will see the same date tomorrow in this field that you see today.

              • 4. Re: Problem with Get ( CurrentDate )

                Let me add to Phil's customarily accurate and helpful comment that you will still continue to see the same date several months from now if you have it stored as a Global value on a file hosted by FileMaker Server, assuming you never shut that file down. (I suspect the same is true if the file is being shared peer-to-peer instead of coming from a server, but I don't have direct personal experience with that situation.)


                What I did to fix my client's particular situation was to declare the field "Today's Date" (on the server) as a Global variable of type Date, not a calculation (with result of type Date) equal to "Get ( CurrentDate )", as it had previously been. Then, as part of the Startup script on the master file in the system, I had a step saying to Set Field "Today's Date" to "Get ( CurrentDate )". That way, whenever an end user opened the file, that field would be updated to an appropriate value, which would remain unchanged for that particular session for that particular user.


                It still wouldn't be foolproof if that user never shut down the master file, but that wasn't a problem at the particular organization I was working with, where they shut down their computers entirely at the end of each day. However, if you're dealing with a situation where even the end users leave their database files open constantly, you'll need to find a more sophisticated way to trigger that update automatically every day.


                Incidentally, knowing "Today's Date" enables you to calculate things like "Age" and "Grade" if you've already stored "Date of Birth" and "Year of Graduation". The virtue to this is that you don't have to keep constantly changing  "Age" and "Grade" manually, the way you would if you'd stored them directly.

                • 5. Re: Problem with Get ( CurrentDate )

                  Note that Get ( CurrentDate ) gets the current date of the local computer, not the server.  It is rarely an issue unless you have people working on a database around the world.  Today's date usually is useful to show what date it is where the end users is.  But if you want to be able to compare when two people were working on sometime and they are in different time zones or dates, but sure that under the hood you are saving the Get ( CurrentTimeUTCMilliseconds ) function to use Coordinated Universal Time from around the world. 


                  Most all computer date systems are based on a number of days since a given date.  In the case of FileMaker, a date is a number of days since January 1st, 0001.  So while it may display a readable date, under the hood, it is just a number.  However, being a number makes is really useful for calculations like subtracting the numbers of days between two dates.  FileMaker does the same thing for timestamps, but it is the number of seconds instead of days. 


                  If in a calculation you ever get a number, just convert it to a date with GetAsDate ( 736398 ) and it converts that number back into March 10, 2017. 

                  • 6. Re: Problem with Get ( CurrentDate )

                    I want to ask something else. I take data from filed with "check" and add to year value from field "period"

                    and this is recorded in the field "next check"


                    Day ( check )&"."&

                    Month ( check )&"."&

                    Year ( check)+period


                    But when day is > 12 it doesn't work. Both fields "check" and "next check" are date fields with format:date.png


                    But it doesn't work. If i set field "next check"  Calculation result is: Number it is wokrs.

                    • 7. Re: Problem with Get ( CurrentDate )

                      Use the Date() function.


                      Date( Day(check) ; Month(check) ; Year(check) + period)



                      FileMaker will handle the math for you. Date returned should be in your system settings.


                      If you really need a "." for a date, then format it so (field in layout mode).


                      Sent from miPhone

                      • 8. Re: Problem with Get ( CurrentDate )

                        Thank you so much !

                        • 9. Re: Problem with Get ( CurrentDate )

                          as a general strategy, using GetAsDate ( get( CurrentHostTimestamp ) )  is the way to go.