Set date to last saturday of the month

hello my good people,

I have a problem of setting a date. I need to set a date on my app to ‘last saturday of this month’. How can i do that?

best Regards

Hi @kla.rity963 :wave:

Download a plugin to give you a list of dates like 1T - List of dates.

With the setup above you will generate a list of the next saturdays…

In some text field (or wherever you want) you can use the formula below:

ListofDates A's List of Dates:filtered:last item

You will pick the list generated by this plugin, filter for the days that are in the current month and pick the last item of the list. This date will be the last saturday

I will try that. Thanks

For what it’s worth and because I like trying to do things using only native Bubble operators, I believe (if I have evaluated it correctly) this expression will always give you the last Saturday of the current month.

saturday

1 Like

What in your expression represents saturday? Looks like this would work only for the current month and no other month

It should work for every month.

Let’s use this February as an example, meaning that you are looking to get a date of February 24th because that is the last Saturday of this February.

The first part of the expression… (((Current date/time + months: 1):rounded down to month… returns March 1st when evaluated for any day in February.

The next part of the expression… +days:((Current date/time + months:1):rounded down to month :extract day * -1))… gets the number of the day associated with March 1st, which in this case is 5 because March 1st is a Friday. The expression subtracts that many days from the date returned from the first part of the expression (again, March 1st), and we get February 25th, which is a Sunday.

The last part of the expression… + days: -1)… subtracts one more day to get us to Saturday. So, now we have February 24th.

Now, let’s say this expression is being evaluated on March 13th (which I picked for no particular reason). We would end up with April 1st (which is a Monday) from which we would subtract 1 day because Monday’s day number is 1 and then we would subtract one more day, and we would have March 30th, which is the last Saturday in March.

1 Like

Thanks. that looks good. My problem is that i would like to do the same for maybe last friday of the month. How would that look like. I’m trying to find the variable which you used to specify that the day should be last saturday. Sorry i don’t have too much experience with this.

I’m not using a variable… the expression always gets the last Saturday because that’s what you said you wanted. If you change the -1 at the very end of the expression to -2, you would get the last Friday of the current month.

Ok. so -1 is the variable then. Great i tried with other days and it’s working. Thanks a lot

1 Like

FYI… I’m not sure why I didn’t think of this in the first place, but I just realized the expression can be simplified to this.

simplified

2 Likes

I applaud the spirit :clap:

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.