Highlighted
Super Contributor.. Super Contributor..
Super Contributor..
314 views

How can I skip the weekends in a date calculation?

We have a caculation written on a date field which is based on normal dates. for this we wanted to exclude saturday and sunday and client holidays. Is there any function in SM for this to achieve?

0 Likes
2 Replies
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: How can I skip the weekends in a date calculation?

Here is an example of an rtecall to the calendar.calc.date.fc application, which I have used in formatctrl to populate a date field based on a start time, a duration, and an existing caldutyhours record. For example, this one would return 45 hours in the future, based on a 9-hour-per-day 5-day work week.

 

$L.rspTime=tod();$L.return=rtecall("callrad", $L.rc, "calendar.calc.date.fc", {"file", "name", "prompt", "times,1", "times,2"}, {$file, "planned.end", "MON-FRI/0800-1700", $L.rspTime, '1 21:00:00'})

 

 

$L.startTime=tod(); establishes the beginning time, which you feed into the RAD call later.

$L.return=rtecall("callrad", $L.rc, "calendar.calc.date.fc", performs the RAD call, specifying which RAD app to execute.

{"file", "name", "prompt", "times,1", "times,2"}, are the parameter names which the RAD app expects. These can also be viewed by looking at the parameter panel of calendar.calc.date.fc in the RAD Editor.

{$file, "planned.end", "MON-FRI/0800-1700", $L.startTime, '1 21:00:00'}) are the parameter values to send into the RAD app. So, we send $file for the current record, "planned.end" as the field where we want the returned value populated, "MON-FRI/0800-1700" as the name of the caldutyhours record, $L.startTime as the beginning time, and '1 21:00:00' as the duration. Note that the duration is in days_hours:minutes:seconds format, so '1 21:00:00' equates to 45 hours.

Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

Re: How can I skip the weekends in a date calculation?

Hi Chandler,

Could you please explain on the duration period, here you have menioned as 45 hours. I didnot get the purpose of using it in this rad function. Also could you elaborate on the result pls.

The  results are as:

Sat Dec 18 -0001 11:00:00 GMT-0700 (Mountain Standard Time)

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.