Exploding a date list from 2 date fields

I have had a squiz through the forum and not found anything that covers what I am asking and am surprised this is not something that has been answered lots of times, and if it has, I apologise in advance.

I have a form with 2 date field on it, imaginatively named startdate and enddate.

I want to have a separate field that contains all the dates between (including) those 2 specified in the fields.

I know I can use @explode to expand a date range. How do I convert 2 date fields into a date range in formula ?

I have tried a number of options including things like

@explode(@date(@text(startdate) + “-” + @text(enddate)))

I just can’t work it out, can anyone explain what I am doing wrong please ?

Subject: Removing weekends from a date list

Re the above, I got that part to work.

I am now trying to return a date list that excludes weekends…

I’ve got this far but it returns nothing, even if I get the formula to add to ‘tmplist’ at both parts of the @IF.

I have prompted N at the end and it is definitely looping as N is a value at the end of it. I presume it’s something simple that I have wrong but have been banging my head against this one for about an hour and gotten nowhere.

Code below :

rem {explode 2 dates into a list of dates};

rem {strip weekends from the list and store in tmplist.};

rem {return tmplist as the results};

stdate := @Text(fmleavereq_startdate_dt);

enddate := @Text(fmleavereq_enddate_dt);

tmpvar := @Explode(@TextToTime(“[”+stdate + “-” + enddate +“]”));

@If(stdate = “” | enddate = “” ;“”;

@Do(

@For(n:=1 ;n<=@Elements(tmpvar);n:=n+1;

@If(@weekday(tmpvar[n])=7 | @Weekday(tmpvar[n]) = 7;

	"";

	@Do(tmplist := tmplist : tmpvar[n])))

));

tmplist

Subject: Typo (you had 2 7’s): @If(@weekday(tmpvar[n])=7 | @Weekday(tmpvar[n]) = 1;

Subject: RE: Removing weekends from a date list

Wow, why write all that code manually? Have you looked at @BusinessDays? Its excludes the weekends (and even holidays if you so choose).

Subject: Exploding a date list from 2 date fields

stdate := @Text(fmleavereq_startdate_dt);enddate := @Text(fmleavereq_enddate_dt);

@If(stdate = “” & enddate = “” ;“”;

@explode(@texttotime(“[”+stdate + “-” + enddate +“]”)))