hcl-bot
February 2, 2007, 10:35am
1
Hi All,
I have a DateRange Field which is multivalue field that has Formula as below
Range := @TextToTime (@Text (StartDate) + “-” + @Text (EndDate));
@Explode (Range)
The values of dates that are stored in the above DateRange (which is a Date/Time Field)
“mm/dd/yyyy”
“mm/dd/yyyy”
and so on.
From the list how can I exclude weekends using formulae…
Plese advise.
Thanks in advance,
carol C
hcl-bot
February 2, 2007, 11:43am
2
Subject: How to exclude weekends in a Date List Field (of Data Type Date/Time) using Formula
Maybe this will help…
@If (EstDate = “” | DateClosed = “”;“”;
EstDate = DateClosed;0;
EstDate > DateClosed;@BusinessDays (EstDate;DateClosed;1:7;HolidayList));
@BusinessDays (DateClosed;EstDate;1:7;HolidayList)))
Subject: RE: How to exclude weekends in a Date List Field (of Data Type Date/Time) using Formula
Hi Nancy,
I am not looking at @Business Days…What I need is that I have a DateRange Field which is a Date Field and is poulating a list of Dates between start Dates and End Dates …
What I need , is how can I get rid of Weekends and repopulate the list without the weekend included.
Here are the values in the DateRange:
“02/02/2007”
“02/03/2007”
“02/04/2007”
…
…
and so on
“02/09/2007”
I need to rebuild the list of DateRange
“02/02/2007”
“02/05/2007”
…
…
“02/09/2007”
Need help
Regards,
carol C
Subject: RE: How to exclude weekends in a Date List Field (of Data Type Date/Time) using Formula
I know it’s been a while since this was posted, but I never found an answer, so here’s a solution I wrote:
REM {part_1: get the full date range};
fullRange := @Eval ( “@Explode ( [” +@Text(DateStart) + " - " + @Text (DateEnd) + “] )” ) ;
REM {part_2: get the ‘weekends’ range};
weekends := “”;
@For ( n := 1; n <= @Elements (fullRange); n := n + 1;
@If(@Weekday(@TextToTime(fullRange[n])) = 1:7 ;
weekends := @Trim(weekends : fullRange[n]) ;
weekends)) ;
REM {part_3: dependant on an ‘incWeekends’ flag display the full or truncated (weekends excluded) range};
@If ( IncWeekends = 0 ;
@Trim(@Replace( @Text(fullRange) ; @Text(weekends) ; "" )) ;
@Trim(@Text(fullRange)) )
In part 3 you could also introduce a replace to remove a list of public holiday dates too, should you have this available. That’s how I’ve used it…