Hello everyone,
I want a solution where I have two dates and I want to find that those dates are the last week date of month.
See image below:
Hello everyone,
I want a solution where I have two dates and I want to find that those dates are the last week date of month.
See image below:
You can take the date, then modify it. Can modify using operators like change hours, date etc.
In this situation you might want to first isolate what is the last week of the year in terms of being a range, from the first day of the week to the last…this would depend on your use case for whether you want that to look at the last day of the month and subtract 6 days to get the real final 7 days of the month or if you want to look at it as a last week of the month which might stretch into the next month.
In the first instance you can use the date you have selected (either from or to would work so long as they are the same month and you can restrict that on the date pickers themselves). Keeping the concept that both from and to dates are in the same month, it makes no difference which you choose to modify to find the last day of that month.
Take the date (either from or to) and then apply operators to change date to 1 (this will make it the date of 1 being the 1st) then extract the dates (either from or to) month (this creates it as a number) and +1 to it, so you now have a date that is the first of the next month.
Then take that and modify it again by doing plus days and use -1 to actually subtract a day. Now you have the last day of the month. That date is the end of your range.
Then take that date which is the end of the range and do plus days -6 to get the start of your range. You now have a start date and end date that are 7 days (a week) as the last 7 days of the month.
Then you need to determine if the dates in your from to are within your range.
As another option. Could you do the start date +days 7 and compare to see if the extracted month is different from each of those dates, making it the last week of the month?
Start date extract month IS NOT start date + days 7 extract month.
Sorry for late reply, can you please give me a example.
I am not getting it, if you can share a editor link of example that will be so helpful.
I’ve created a quick demo for you below.
This is the link to the editor
I’ve done the following:
Good work. I think the OP wanted to know if the dates from the date pickers the user interacts with are in the last week of the month for which the date is, and not necessarily the last week of the current month…but of course I could be wrong as it is not very clear from the post.
Hi there, I was wondering if you can show us a sample or share an editor on how you execute this? this would be helpful too
This topic was automatically closed after 70 days. New replies are no longer allowed.