AnsweredAssumed Answered

Help with a date calculation

Question asked by esizela on Mar 13, 2018
Latest reply on Mar 15, 2018 by beverly

Hello all... this is my first time on the community and from what I can tell you are a very helpful bunch of people so I am optimistic about getting a great result to what I assume is a relatively simple question.


I am a very new user of FM and not by any means a developer.


I have a program for bookings and what I need for it is to calculate the total of days from 2 'date' fields. The fields are 'days', 'arrival' and 'depart'.


I have the basic calculation set as 'depart - arrival' which works almost perfectly with a couple of glitches.


1. When the depart and arrive dates are the same the result is obviously 0 and I need it to be 1. I currently have entered a Floor (1) which seems to give me the 1 I need upon creation (using the current date as a default in both fields) but I am sure this is not the best way and tbh I am not sure that the Floor function is meant for this use...


2. (This issue may not exist with the suggestions you may make for me but at the moment)...If the dates are changed from the originals (today's date in both fields) the calculation works fine. If I however change it once and then change it back to both fields with today's date, the calculation keeps the last result. It forces me to change the days to have 1 day difference and then back to same same.


In what I assume is very basic English, I need something like this


Calculate (depart - arrival)

If the result is '0' please + '1'

If either of the date fields are modified for any reason please re-apply the initial calculation


Additional notes... the result should never be a negative number (and should not be so long as the dates are entered correctly) and, it would be handy (if not overly complicated) to add something in order to block me from accidently entering an depart date that is before the arrive date and vice-versa...


I hope this all make sense and thanks in advance for any helpful advice..