Question
1
Replies
104
Views
Posted: June 5, 2020
Last activity: June 5, 2020
How to add business days to Datetime property to get Datetime result
Hi I have a requirement to add no of days to datetime property and get the result include calculating the business days. So i have tried using this
@BusinessCalendar.addDays(( .pxCreateDateTime),@String.toInt(.PriorityDays),true,"ING")
but unfortunately it's returning datetime format where date part is proper but time isn't getting added and instead it's resetting to 00:00:00.
Please help me if anyone has anything alternative.
Thanks already.
Akhil
Hi,
You can try as below,
pxGetSpecifiedTimeOnDate(@BusinessCalendar.addDays((.pxCreateDateTime),@String.toInt(Param.PriorityDays),true,"USDefault"),@DateTime.FormatDateTime(.pxCreateDateTime,"HH","America/New_York",""),@DateTime.FormatDateTime(.pxCreateDateTime,"mm","America/New_York",""),"00","America/New_York")
Here I changed .PriorityDays to Param.PriorityDays and "ING" to "USDefault" for my testing as I don't have that property and business calendar ING on my system. Also I used time zone America/New_York. Please change based on your requirement.
If you see in below screenshot .pxCreateDateTime is given as June 12, 12.28 PM in America/New_York time zone. June 12 is Friday and when we add 1 to that it returns June 15 with time as 16.28 in GMT which is same as 12.28 in America/New_York.
I saw another function @DateTime.TimeDifferenceBusinessDays() which I thought might work based on description provided. I couldn't try as it was giving some error for me.