Selecting Full Weeks or Full Months

Hi,
I’m facing two challenges that I don’t know how to solve.

Challenge 1:
I need the user to be able to select a full week in the year BUT the “offered weeks” needs to start on a Sunday and end on the following Saturday (e.g. from 2020-01-05 to 2020-01-11). I would like to save both the start and the end dates of the chosen week in the database.

Challenge 2:
Similarly to the above, I need the user to be able to select any month in the year. The “offered months” needs to start on Day 1 of the month and need to end on month end (e.g. 2020-02-01 to 2020-02-29) . Once again, I need to save the start and end dates of the chosen months.

I focused on the first, assuming that a solution for the second will follow the same or very similar pattern, and tried these alternatives:

  1. Use an Input field of type Week. I hit two problems: the week starts on a Monday, not on a Sunday and the saved value looks like 2020-W02. I could not figure out how to extract the start and end dates from this.

  2. Use a Date Range Picker. Although this widget seems to have a good way to segregate start and end date on the server side (I think Teodor wrote an excellent article for it), I can’t seem to be able to force the selection of full weeks that start on a Sunday.

  3. Two input types of type Date. Call them StartDate and EndDate. If only I could force StartDate to accept only Sundays, I can easily force EndDate be 6 days later. But I don’t know how to do that.

Unfortunately, none of them got me to the end line, so any guidance on how to attack these challenges would be really appreciated!

Alex

Community Page
Last updated: