I am trying to hide a field on my form if the date of my "departureDate" field is before 1/3/19 (first of march 2019.)
Any help greatly appreciated. I feel that i must have tried every combo except the correct one. The idea is a text box ("BrexitWarning) appears if staff are planning to travel abroad after this date
Solved! Go to Solution.
You should be able to accomplish this using the 'DateDiffDays' runtime function evaluating the difference between the date you are running against, the current date, and the date entered in the control. To show behind the curtain a bit, I am using a calculated value control, but the same setup could be done using a form variable if you dont want to show the date differential on the form.
First, add your date picker control, your warning label and your calculated value control (or form variable).
Next specify a name for your date control
Next configure the calculated value control with the DateDiffs. Specifically in this scenario I am wanting to calculate the time between the date control and today and the time between the Brexit warning and today. This will look something like dateDiffDays(Date, Current Date) - dateDiffDays(Current Date, "2/28/2019")
Make sure you also specify a name for this control if you are using a calculated value.
From there, you'll setup your rule to hide the Brexit warning using the name of the calculated value control (or form variable) and use a less than or equal to <= "0".
Here are a few dates specified. **NOTE**I'm using an American calendar so the dates will be flipped for you.
I'm leaving the first response as it might help people with date differentials, but I was overthinking it. The easiest way of doing this would be the configuration below:
Keep the configuration with the date control described above. I named the control Date. Setup a rule on the label control to hide with the formula with date <= convertToDate("2/28/2019")
Below is rule firing and hiding the Label on an early date:
Below is the later date that will trigger the control showing on the form:
Brilliant stuff Dan, thank you very much. I have learnt two things . I started at the top but was not sure why you had the larger formula and i used a variable and the formula - dateDiffDays(DepartureDate, "15/04/2019"), as date diff only gives a positive value (3rd thing learnt), I used a date a few weeks after the date then hide when the variable was under 15 (this basically hid the control except during April). I then used another rule to hide when departure date was blank.
Then i read the bottom bit, had a laugh then made that work too.
Obviously there is always more so....
I was looking at hiding between dates using your second method (convertToDate). I was using between say jan 20th and jan 25th as an example. I have used every combo of <> && || , except perhaps the correct one . I see it is easy using two rules, one for each but it would be tidier if i just used 1. Thanks again for you time on this, much appreciated.