Date Picker Default to 20 Years Ago

How can I set the Date Picker to show the current date minus twenty years by default?

AFAIK, the date picker isn't object based so there's no way to do something like this at runtime:

dataPicker.setDate(<date_here>)

I don't believe there's even a way to set the date statically in a config file or something like that.

Great question. :slight_smile:

Use a JS data picker that does let you set all of its properties?

Just thought of an idea for a (crude) workaround:
Create the first Record and manually set the Date to "26/06/2000". Leave all other Fields blank.
Script the "Create New Record" Button to - (instead of creating a new Record) - duplicate this first "blank-Record-with-Date-set-to twenty-years-earlier".
Will have to change the record every year though...

It seems the date picker defaults to the date of the field it is based on. When blank, it defaults to today.

So you could set the field value to what you need, and revert the record if the user does not select a different date. But it leaves you with the problem of dealing with if the user exits out "without" making a selection, or happen to make a selection for the exact date you pre-filled in there. Something like that could be hard to detect, and because you are using the actual field, doing a comparison with the value prior to when the user started to interact with the date picker is not easy either.

That said, it feels like if you can spare using one extra global field, the comparison can be a bit easier, trapping for "no selection" will still prove difficult.

Finally, the Date Picker also answers to arrow keys, if you can send keystrokes, it would let you "select" a date in this fashion. One key press moves you one day in a direction. For a few days, the user may not notice anything. For 20 years, even if automated, it could be visible and I don't think you could prevent it from displaying what is going on.

If you are ok with using a JS based picker, that may be your best option. (as mentioned by Wim)

1 Like

What's up with this topic title changing like this? Seems quite different from the original question.

Did it have a different subject initially? All the posts came to me via email with the same subject.

It was something to do with Date picker. I have a difficult time reconciling the topic with the OP's question. It looks like there's no modification history (maybe this is not tracked or maybe the modification was done within a "grace period" not triggering what logs that kind of change)

The subject of the initial message in my email thread is the same as this. The question in the body is simple and clear, it's about setting the date picker to today minus twenty years.

Email is lagging behind the app. Can you tell me what is the link between conditional formatting and the question about the date picker? I'll be happy once I understand that part.

I have no idea :smile:

Hi all,
This was my first time on FMSoup and so I didn't notice the message header said "conditional formatting".
That's all.
Would love to change the subject header, if only someone (moderator?) could show me how or do this for me.
Thank you all for the valuable input!

Look for the pencil icon to the right of the header. You should be able to edit it.

@calculu great to see you posting content. I hope to hear more of the things you want to share as you get more familiar with Discourse.

Make sure to let us know what you end up doing about this specific case of wanting to control the picker's display...

Add the following Calculation (to the Field where you want the Pop-Up Calendar to show minus twenty years): "Get ( CurrentDate ) - 7305".