5 Replies Latest reply on Aug 9, 2014 5:04 PM by isaaclhaywood

    Timestamp calculation

    isaaclhaywood

      Title

      Timestamp calculation

      Post

           I am having some trouble creating a timestamp calculation.

           I need to specify a field to fetch the current timestamp in hours and add say 5 hours each day creating a running total.  Then when the hours reach 500 I need it to populate a alert in my main menu layout. Any help with this would be greatly appreciated! 

           Also would this calculation be written in the fields then specify calculation?

           I tried Get (currenttimestamp) with always validate on but it does not seem to work. 

           Thank you in advance

        • 1. Re: Timestamp calculation
          philmodjunk

               First, a key detail on timestamp Values. The date and time shown in a timestamp field is computed from a stored integer that counts the number of seconds that have elapsed from Midnight, 12/31/0000 to the date and time displayed in the field. So when you add or subtract values using timestamps, you must add and subtract the needed values in seconds, not hours.

               To to enter value that is the current time stamp + 5 hours, you would use this expression:

               Get ( CurrentTimeStamp ) + (5 * 3600) // there are 3600 seconds in an hour

               In a script, set field can set a field to that expression.

               In a TimeStamp field, you can use an auto-enter calculation to enter that value each time a new record is created in that table.

               But you have also specified a running total. What kind of running total of a TimeStamp are you trying to compute here? I can't quite picture a running total timestamp value.... Can you provide an example of what you want?

          • 2. Re: Timestamp calculation
            isaaclhaywood

                 Hey Phil,

                 Okay, I understand the time thing now thank you! I am building a maintenance log specifically dealing with lighting repairs. One part of this log is tracking Lamp Hours and Fixture Cleaning.  At say 500 Lamp Hours the lamps in the fixtures need to be changed .  So I would like to automate the calculation by having Filemaker count say 5 hours a day (which is how long the lamps are on a day) and then post in the maint log on the main Menu that a certain fixture needs to have its lamp changed after it has hit the 500 hour limit. OR that the fixture has not been cleaned in say 2 months and could use a cleaning.  Sorry if this a little confusing.

            • 3. Re: Timestamp calculation
              isaaclhaywood

                   I know I could create a second log table and then on the main Menu create a portal. Then I could make a script to post a text into the last field which would make the repair log.  Also after thinking about it could I just have the lamp change populate after a certain number of days instead of hours again not to sure how to make that calculation though. 

              • 4. Re: Timestamp calculation
                philmodjunk

                     500 lamp hours / 5 hours per day = 100 days of operation (which may not be 100 calendar days if facility is closed on weekends or certain holidays...

                     Avoiding that complication just to get the ball rolling, a date can be computed and stored in a date field by adding the number of days to it.

                     So if a date installed field records the date the new lamp was installed, a ReplacementDate field could be computed as Date Installed + 100. And Date Installed + 60 would compute a cleaning date for that lamp.

                • 5. Re: Timestamp calculation
                  isaaclhaywood

                       Hey Phil sorry I have not responded yet, had to put this on the back burner for a bit.  I did finally figure it out with your help thank you so much.