5 Replies Latest reply on May 21, 2015 1:04 AM by fluffyone

    number from time and date

    fluffyone

      Title

      number from time and date

      Post

      Hi Group

      is it possible to have a field generate a number from the time and date numbers with no other characters?

      i.e...  if the time and date was:   16:40 and 24 seconds 19/05/15
      when the field was activated by a button press the field would result in:
      164024190515 as a number only

      is this possible?

       

      regards Fluffy

        • 1. Re: number from time and date
          nicolai

          GetAsNumber(GetAsTimestamp ( " 19/05/2015 16:40:24" )) which will give you 63567650424which is a number of seconds between your  timestamp and  1/1/0001 12AM. Internally FileMaker stores dates and times as numbers, this helps calculations and displaying different formats

          If you need a different format, like the UNIX timestamp, you will need to adjust the number of seconds accordingly.

          • 2. Re: number from time and date
            fluffyone

            Hi Nicolai

            thankyou for your input 8-)

            so basically where you have  " 19/05/2015 16:40:24"  this will be the time stamp created by filemaker as of that moment I press my button etc.. and the getasnumber command will work from that date/time set in the time stamp field from   "1/1/0001 12AM".  so every number calculated will be unique and increasing in value each time?

            regards Fluffy

            • 3. Re: number from time and date
              nicolai

              That's correct. Instead of GetAsTimestamp ( " 19/05/2015 16:40:24" ) you can use Get(CurrentTimestamp)

              Full calc would be GetAsNumber(Get (CurrentTimestamp))

              This way you do not need to construct the timestamp yourself.

              The number is going to be unique, unless user manages to press button twice in a second. If it is a problem, just add one second pause to your script. 

              • 4. Re: number from time and date
                philmodjunk

                If you set a number field to the value of Get ( CurrentTimestamp ), you don't even need GetAsNumber to get the numeric value. Note that if you want to use this as a primary key, an auto-entered serial number is simpler to implement and get ( UUID ) is also a better option.

                If you have multiple users all creating new records at the same time, it's quite possible for two records to get exactly the same time stamp, but a serial number of OR UUID will still be unique.

                • 5. Re: number from time and date
                  fluffyone

                  Hi Nicolai  and PhilMod

                  bother great answers and solutions, thankyou.

                  regards Fluffy