Use of Show when to display a text field for today or future date

I need to display a text field ,if the date selected is today or Future date.

Can anyone help with the code.

Note: Future date can be after 5 month also 

Am able to display text if selected date is today.

Here is my code:

showWhen:if(local!selectedDate= today(),true,false) 

 

I know we can do something like today()+5 for 5 days from today

is there any better way

  Discussion posts and replies are publicly visible

Parents
  • So, first let's look at the syntax. You have a redundant if() statement. showWhen takes a Boolean vakue, which can be true or false,. So as long as your expression returns a true or false - e.g.local!selectedDate=today() - then you do not need the if() statement.

    Now to your actual problem. It's not clear if you mean 5 months or 5 days from today. I'll take a look at each:

    1. make this text field visible if selected date is today or 5 days from today:

    showWhen: or(
    local!selectedDate=today(),
    local!selectedDate=today()+5
    )

    2. make this text field visible if selected date is today or 5 months from today. 

    This depends onw hat you mean by "5 months from today". Do you mean the 5 x 4 weeks from now? If so that's just a simple calculation where you multiple the 4 weeks by 7 days and add that on as per the previous example. But there may be other definitions of "month" that you have in mind?

Reply
  • So, first let's look at the syntax. You have a redundant if() statement. showWhen takes a Boolean vakue, which can be true or false,. So as long as your expression returns a true or false - e.g.local!selectedDate=today() - then you do not need the if() statement.

    Now to your actual problem. It's not clear if you mean 5 months or 5 days from today. I'll take a look at each:

    1. make this text field visible if selected date is today or 5 days from today:

    showWhen: or(
    local!selectedDate=today(),
    local!selectedDate=today()+5
    )

    2. make this text field visible if selected date is today or 5 months from today. 

    This depends onw hat you mean by "5 months from today". Do you mean the 5 x 4 weeks from now? If so that's just a simple calculation where you multiple the 4 weeks by 7 days and add that on as per the previous example. But there may be other definitions of "month" that you have in mind?

Children