I’m building an app where users can track their monthly expenses. I want to give the user the option to not only see the current month’s expenses, but also see the expenses of (at least) the last 2 months.
In the onboarding the user enters the default start date of his/her financial month. In theory this could be any given day of the month. For instance, if a user enters 21 as the start date, each month would run from the 21st up to the 20th of the following month.
What is the best way for setting this up in the database in order to keep the app performing well? I think in the user tabel I need a field with the default start day (21 in the example above), a field with current month’s start date, a field with current month’s end date. And then fields for previous month’s start data, previous month’s end date, two month’s ago start date and two month’s ago end date.
However this feels a bit cumbersome, there must be some easier way in setting this up. Does anyone have experience with this and could point me in the right direction?
Any help would be appreciated.