Hey Bubble Fam,
Hoping you can help…
A user defines a date range, and submits it in one data type. I then need to create new thing in another data type for each week that the original date range falls in.
Original date range
Weds Sept 18 2019 - Fri Sept 27 2019
Results in two new ranges:
Mon Sept 16 - Sun Sept 22 2019
Mon Sept 23 - Sun Sept 29 2019
Thinking I could use an API to achieve creating as many new things as weeks this but not sure how to go about it.
I think I can see a similar way of how to: take the start date of the range, convert that to a new range of the week that it falls in. I think, I can sort out the following weeks being generated later in the user journey once I have the first one.
I was trying to use the create new thing function, and take the weekFirstDay= startDate+(days): - startDateExtract:day-1 …but it wont let me add the subtract in front of the the last part or the -1 on the end…?
So far I think these other posts are on the edges of what I need to implement but still struggling to make the jump over to what I’m trying to do…
Get Week, Month, and Year from @mebeingken
How to find the data of next Monday from @romanmg
@louisadekoya Been experimenting adapting your reply to find the following Sunday into a workflow.
Not sure I’m doing it quite right tho because I can’t seem to make it work :s I assumed ‘moment’ was the current date/time, so I subbed that with the start date which I want to work from…
And then in the following step:
Any help would be appreciated.
Happy to try to help but I’m not at a computer right now, so some of what I write below may not be in the exact syntax needed and you may have to check other examples to be sure.
First of all, make sure you are using moment.js, i.e did you add the momentJs script call to your page header as in my post?
Then to answer your question, yes ‘moment’ in the code I posted did refer to the current date in that example but you can pass a different date to moment and assign it to a variable.
This is where I’m unsure of the syntax without checking but something like:
var myDate = moment(“20190918”,“YYYYMMDD” );
You should replace the date with your dynamic date formated as YYYYMMDD.
Then in the code from my post (or in the code below which may be closer to what you need) , you should be able to replace ‘moment()’ with myDate.
var startOfWeek = moment().startOf('isoweek').toDate();
var endOfWeek = moment().endOf('isoweek').toDate();
This topic was automatically closed after 70 days. New replies are no longer allowed.