4 Replies Latest reply on Aug 5, 2014 4:43 PM by ChristopherKessler

    Format number as months and days

    ChristopherKessler

      Title

      Format number as months and days

      Post

           I have an "age" field that is a number calculation based on the current date and an animal's date of birth. I would like to have this field be the number result of this calculation so animals can be searched for by age, but I would like it to be displayed as "Months" and "Days". For instance, if an animal was born two and a half months ago, this field's value would be ~75, but I would like it to display "2m 15d" or something similar when viewed. Is this possible, or would the better approach be to simply duplicate the field and have it calculate the months and days as text? I can do this, but would prefer to have it all be in one field, similar to how dates are in the format mm/dd/yyyy, but you can have FMP display them in any format.

        • 1. Re: Format number as months and days
          philmodjunk

               You'll need a calculation field to get that result. A number of threads here show this type of result for an age calculation.

               Though if you define a "month" as always 30 days in length, the calculation is much simpler.

          • 2. Re: Format number as months and days
            ChristopherKessler

                 Thanks, but that was not my question. I know how to make a calculation that outputs a formatted text string in months and days. I am wondering if this is possible to do as a mask over a given field. I want the field to hold a number value of the age in days, but want the field to only display the value in months and days, if possible.

                 The problem with using a calculation is the value becomes "2m 15d" instead of a searchable value of 75, and this prevents searching for a range of ages, such as finding all animals that are between 30-60 days of age. The point here is to have the field's functions be in days, but have it simply display in the more readable formatting of months and days. Is this possible?

            • 3. Re: Format number as months and days
              philmodjunk

                   It is not possible. That's why I posted that you would need to use a calculation to get this result.

                   

                        The problem with using a calculation is the value becomes "2m 15d" instead of a searchable value of 75,

                   But having one calculation field that returns the value in months and days does not keep you from also keeping the original calculation field that computes the age strictly in days so you can still search with ranges in inequalities as long as you search on the original calculation field not the new one.

              • 4. Re: Format number as months and days
                ChristopherKessler

                     Sounds good. I'll do this and have the field simply show and hide conditionally when in find or browse modes.