# Compute start date of a monthly billing cycle

Struggling with this problem.

Suppose a user’s subscription date is Dec 10, 2021.
I need to compute the start date of the current monthly billing cycle.
Mentally I do this by computing the number of months from then till now (2+ months), then adding 2 months to the subscription date, to get Feb 10, 2022.

i.e.
Start date of current billing cycle = floor(months(curr_date - sub_date)) + sub_date

But I can’t figure out how to do it using the functions in Bubble. There isn’t a function where I can find the difference in terms of months.

Any idea? Or is there another way of achieving the same thing?

Hey @jayy

You can use ‘rounded down to’ after a date to achieve what you are looking for. You can round down to month and day if need be. Rounded down to month will take you to the first of the month. Rounded down to day will take you to midnight of the day.

You might need to do this in a separate step in order to achieve what you are trying to do. Then you can do that math on both dates. Try using set states to temporarily hold those values.

Does that make sense?

1 Like

Thanks a lot. I decided to start every billing cycle on the 1st of the month to keep it simple.

1 Like

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