### Post

2 followers Follow

# Get all mondays between two dates

HI all,

i have 2 date field : From & To

Ex: From = 20/10/2018 & To = 1/2/2019

How can i get the list of Monday from 20/10/2018 to 1/2/2019?

Result:

21/10/2018

28/10/2018

04/11/2018

....

28/1/2019

Thanks

Ninh

`Hi Ninh,var start = moment(@from);var end = moment(@to);var len = diff.end(start, "d");var result = [];for(var i = 0; i < len; i++){     if(a.add(i,"d").isoWeekday() == 1){       result.push(a.add(i,"d").format("DD/MM/YYYY"));    }};result.join("\n")`

Rainer

Thanks Rainer,

in your code: i don't know variable "a" . Is a = start?

This code:

var start = moment(@from)
var end = moment(@To)
var len = end.diff(start, "d");
var result = [];
for(var i = 0; i < len; i++){
}
};
result.join("\n")

======

i have tried, Ex: From = 20/10/2018 & To = 1/2/2019 but result:

01/10/2018
28/10/2018: wrong
20/11/2018: wrong

...

19/01/2031: wrong
30/09/2031: wrong
13/03/2033: wrong

Can you look again? Thanks

Hi Ninh,
I'm very sorry - my bad.
First: yes, a = start
Second: start must be declared as moment().

`var start = moment(@from)var end = moment(@to)var len = end.diff(start, "d");var result = [];for(var i = 0; i < len; i++){if(moment(start).add(i,"d").isoWeekday() == 1){result.push(moment(start).add(i,"d").format("DD/MM/YYYY"));}};result.join("\n")`

That should work.