Hi,
I want to display weekly metrics on my dashboard and am trying to figure how what formula I need to create for the Collection. The week would not be the last 7 days but from the Monday of the current week.
Thanks
Hi,
I want to display weekly metrics on my dashboard and am trying to figure how what formula I need to create for the Collection. The week would not be the last 7 days but from the Monday of the current week.
Thanks
Depends if you’re using the data plugin for weweb or custom javascript
If you’re using javascript you can use something like this to get the start of the week
const today = new Date();
const dayOfWeek = today.getUTCDay();
const startOfWeek = new Date(Date.UTC(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate() + (1 - dayOfWeek)));
This will give you the start of the week in UTC time format you can use 0 to be Sunday to do somerhing similar for the end of the week.
Thanks. Will give it a try.
Ok, it worked.
The only change was the last line which is -
return monday.toISOString().split('T')[0];
And as an FYI to others, I did this in a page workflow - On Page Load → Change Variable Value.