How to select a date by format of yyyy/MM?

0
Hi all, I think that I want to like to select date in the form of 'yyyy/MM' instead of 'yyyy/MM/dd'. Please teach me if anyone knows how to do it.
asked
3 answers
2

You could create an enumeration for the months, since most years have the same number of months in them... and for the year you could create an integere attribute. The combination of these two can easily be combined into a datetime() function to create an actual datetime attribute, if you'd like. This way you don't have to check and parse any strings. Also see: https://docs.mendix.com/refguide4/date-creation

answered
1

I would create a non persistant entity with a string attribute and in the reference selector use a microflow to create the 12 objects where you fill the strings with the years and the months (this way you can make sure that always the coming twelve months can be selected). In the on change microflow you can then use the selected option to create the date from the string and save this date in the entity that holds this value. Hope this helps.

Regards,

Ronald

 

answered
1

If it is only for display purpose you can also use a normal date attribute and select the date format of the Date picker as 'Custom' with custom date format 'yyyy/MM'. So you select a specific date but the yyyy/MM is shown on your page.

 

Regards,

Roel

answered