Question

add days to datetime property using business days

I would like to add days to a datetime using only business days. The function DateTime.addToDate add a number to a date but doesn't use only business days.Are there any functions that add number to a datetime using only business days?

**Moderation Team has archived post**

This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.

Correct Answer
September 12, 2017 - 5:22am

Hi All,

Thanks for all the help.

I got the issue resolved, actually when we use @differenceBetweenDateTimes(Param.StartTime,Param.EndTime,True,"");

when the calendar parameter is blank it takes the Calendar as Default, Default calendar is an instance so i have saved as the default calendar instance, earlier the time was mentioned as 08000 to 170000 that the reason it was giving as 9 hours range i have changed that to whole day as working so now gives result in 24 hours range.

 

Comments

Keep up to date on this post and subscribe to comments

July 24, 2017 - 9:13pm

Hi Saurabh,

Business days is not a standard defined set of days and may vary depending on place, organization and on other factors. There may also be holidays which will not be considered as a business day thus the definition is dynamic in nature. 

I am assuming you are referring to Mon-Fri weekdays by business days. You may thus have to write a custom function to achieve this. 

 

Regards,

Faizan. 

 

July 25, 2017 - 8:56am
Response to FaizanFayaz

Hi Faizan,

I am trying to use Calendar rule to calculate days which will cover Monday to Friday and Holidays too. I have found 2 functions also but somehow those I am not able to provide because of error "rule instance not found".

pxAddTime and TimeDifferenceBusinessDays are those 2 functions.

Pega
July 25, 2017 - 9:29am
Response to SaurabhG2392

Try saveas the function in your local ruleset or create a new function with the same code.

July 25, 2017 - 3:30pm
Response to kakul

I have tried this but getting same instance not found error.

July 25, 2017 - 10:28am

Try this :

  • @(Pega-RULES:BusinessCalendar).addDays(<PROPERTY>, <Integer of days to add>, true (consider business calendar), OperatorID.pyCalendar (get operator calendar))
  • if passed from agent -- please pass OperatorID.pyCalendar as parameter.

July 25, 2017 - 12:14pm
Response to AkshaySinha

Hi Akshay,

I tried this option but this function return only Date portion and I am looking for DateTime value in return.

September 8, 2017 - 8:28am

I am also facing the same issue if someone have solution please share, Thanks in Advance.

September 8, 2017 - 8:53am
Response to SHOAIBAHMED

What is the use case you are trying to solve? You can also utilize functions which calculate the difference between dates --> @(Pega-RULES:BusinessCalendar).differenceBetweenDays

Kip | Community Moderator | PEG

September 8, 2017 - 9:03am
Response to KipJackson_GCS

I need to get the difference between 2 dates excluding the weekends

September 11, 2017 - 6:42am
Response to SHOAIBAHMED

Unfortunately my original reply did not include the images.

 

Kip | Community Moderator | PEG

September 11, 2017 - 8:25am
Response to KipJackson_GCS

Hi,

Thanks a lot for the response, I am aware of those functions but my requirement is bit different.

The function differencebetweendatetimes gives the difference in seconds based on the business calendar and business hours.

But my requirement is something like below.

My Start Date is 20170908T102818.445 GMT and End Dtate is 20170911T102818.445 GMT i should get the difference by excluding sunday and saturday alone that means i should get the difference as 1 day. But the above function differencebetweendatetimes is giving output as

@differenceBetweenDateTimes("20170911T102818.445 GMT","20170908T102818.445 GMT",true,"") == 32400 Seconds

It's totally calculating based on business hours for one day means it's returning 9 hours but in my case i need to get the time in 24 hours format, 1 day means 86400 Seconds.

September 11, 2017 - 8:30am
Response to SHOAIBAHMED

For example when i am using as @differenceBetweenDateTimes("20170911T222818.445 GMT","20170911T212818.445 GMT",true,"") i am getting the difference as 0 seconds but it should return the value as 360 Seconds ie 1 hour

September 12, 2017 - 5:22am
Response to SHOAIBAHMED

Hi All,

Thanks for all the help.

I got the issue resolved, actually when we use @differenceBetweenDateTimes(Param.StartTime,Param.EndTime,True,"");

when the calendar parameter is blank it takes the Calendar as Default, Default calendar is an instance so i have saved as the default calendar instance, earlier the time was mentioned as 08000 to 170000 that the reason it was giving as 9 hours range i have changed that to whole day as working so now gives result in 24 hours range.

 

July 28, 2018 - 1:43pm
Response to KipJackson_GCS

can i know how to open the that instances of function tab above

November 17, 2017 - 8:31am

How about getAsBusinessDay function. I tried it but its not working as intended.

February 21, 2018 - 5:28am

Hi i am taking 2 inputs using datetime and want to calculate the number of business days between them ! Please explain what exactly did u do

July 29, 2018 - 9:51am

Hi,

i think your question is answered by shoaib.