2 Replies Latest reply on Oct 29, 2011 7:54 PM by KenL_1

# Problems with getting days as a form of weeks, years etc,

### Title

Problems with getting days as a form of weeks, years etc,

### Post

Hi folks, Im a beginner of FileMaker Pro.

I was trying to get a field called "Length" display a correct value in its corresponding unit, which is a calculation field that calculate the Current Date minus the Created Date of a data.

Therefore, the calculation would be Get (CurrentDate) - Joined Date, and this gives the value in Days as default.

However, I want to make the field becomes more "user-friendly'. In which, I tried to use IF statement to get the correct unit. For example, if Get (CurrentDate) - Joined Date < 7, the unit behind the calculated value would be week(s), and if it is over 28, then month(s) and so on. But I have no idea how should I achieve this sort of calculations as all I know about IF statement is that you can only allow a result displayed/filled into a field with "value/text". What I mean here is something like,

If( Get (CurrentDate) - Joined Date < 7 ;  "Length week(s)")

I know this doesn't make any sense to the calculation but this is the only way I could think of.

And also I don't know how or can I actually Look-up a field's value as a IF statement result once an IF condition is met.

So I hope someone here could help me out or suggest a better solution for it.

Thank you.

• ###### 1. Re: Problems with getting days as a form of weeks, years etc,

I read that to be that you want a result with different  types of units. Short intervals in weeks and longer intervals in months and very long intervals in years. If so, then use a Case function instead of If:

Let ( I = Get ( currentdate ) - Joined Date ;
Case ( I < 7 ; I & " days" ;
I < 30 ; Round ( I / 7 ; 1 ) & " weeks" ;
I < 365 ; Round ( I / 30 ; 1 ) & " Months" ;
/* else */ Round ( I / 365.25 ; 1 ) & " Years" ;
) // Case
) // Let

• ###### 2. Re: Problems with getting days as a form of weeks, years etc,

Yes sir, this is exactly what I wanted to do and it looked simple enough.

Thank you so much!