6 Replies Latest reply on Jan 29, 2011 7:55 AM by Polarpro

    How to make sure that Get(CurrentHostTimestamp) *always* shows seconds

    Polarpro

      Title

      How to make sure that Get(CurrentHostTimestamp) *always* shows seconds

      Post

      Hey,

      Unfortunately, when a timestamp that I got by using the Get(CurrentHostTimestamp) function has a "full" minute (i.e. 00 seconds), the timestamp only shows 29.01.2011 02:34 instead of 29.01.2011 02:34:00. I want the seconds to be seen even when they are 00. It seems that there a few workarounds, but wonder if there is an easy or "native" way to fix this.

      :-) Mike

        • 1. Re: How to make sure that Get(CurrentHostTimestamp) *always* shows seconds
          Frinholp

          Hi Polarpro

          I encountered the same problem a while back.

          No native way to solve this as I'm aware.

          It all depends in what situation you require the stamp and what version of FM you are using; developing in FM Pro allows you to create Custom Functions.

          In my case a requirement was to store a time stamp when a certain script was executed. When that script is executed I call a custom function improvedTimestamp() to be stored in a field.

          Fieldname = improvedTimestamp()

          Function defined as:

          If (Length ( GetAsTime(Get(CurrentHostTimeStamp))) = 5;  GetAsTime(Get(CurrentHostTimeStamp)) & ":00"; GetAsTime(Get(CurrentHostTimeStamp)))

          If you are not working with a FM Pro version you can create a calculated field, called say

          cImprovedTimestamp = If (Length ( GetAsTime(Get(CurrentHostTimeStamp))) = 5;   GetAsTime(Get(CurrentHostTimeStamp)) & ":00";  GetAsTime(Get(CurrentHostTimeStamp))) that field will now contain the current  timestamp with 00 seconds.

          Lee

          • 2. Re: How to make sure that Get(CurrentHostTimestamp) *always* shows seconds
            Polarpro

            Hey Lee,

            Thank you for your answer.

            What you write helps; my situation is pretty much the same: When a certain script action is being performed I need to get a timestamp (in this case for a history field that lists the actions of the records).

            Though my problem is a bit more of an "aesthetic" issue, the users would find it awkward if some zeroes don't show up in their records' history fileds:

            29.01.2011 00:59:33        John Baker: Request filed.
            29.01.2011 01:08:30        John Baker: Request changed.
            29.01.2011 01:09             Tom Smith: Request changed.
            29.01.2011 01:19:49        Colin Scott: Request approved.

             

            Mike

            • 3. Re: How to make sure that Get(CurrentHostTimestamp) *always* shows seconds
              Frinholp

              I am still unclear if your version of FM allows you to create custom functions?

              Are you explicitly stamping the date using GetAsTime(Get(CurrentHostTimeStamp))?

              When and what is currently stamping the date? You by script or calculated field, or are you using a native function to do this?

              If you are using GetAsTime(Get(CurrentHostTimeStamp)) to append or write to a field, and you are using FM Pro, create a custom function using the code I provided in the above post.

              In place of using GetAsTime(Get(CurrentHostTimeStamp)) call the custom function and the two zeros will be appended.

              Lee

              • 4. Re: How to make sure that Get(CurrentHostTimestamp) *always* shows seconds
                Polarpro

                Sorry for not having been clearer.

                Yes, I use FM Advanced an can create custom functions. Here is the one the I called ImprovedTimestamp:

                Let (
                ITS = Get ( CurrentHostTimestamp )
                ;
                Case (
                Length ( GetAsTime ( ITS ) ) = 5; GetAsDate ( ITS ) & " " & GetAsTime ( ITS ) & ":00" ;
                GetAsDate ( ITS ) & " " & GetAsTime ( ITS )
                )
                )

                The timestamp formatted this way is being set when a script runs it.

                • 5. Re: How to make sure that Get(CurrentHostTimestamp) *always* shows seconds
                  Frinholp

                  Sorry I meant Advanced not Pro.

                  Your function works perfectly. In fact an improvement on mineLaughing

                  I am assuming all is good now?

                  • 6. Re: How to make sure that Get(CurrentHostTimestamp) *always* shows seconds
                    Polarpro

                    Thanks a lot, things seem to work well. Strange that FM has such a weird format for full minutes...

                    Smile