Skip to main content
manavik105
November 8, 2023
Question

how to convert a workday function output to Date & Time instead of just date

  • November 8, 2023
  • 5 replies
  • 0 views

Hi All,

I want the output of a workday function to be Date&Time instead of just Date. Please advise on how I can wrap the below logic to get the output as Date& Time:

workday(
todatetime("01/01/2024 7:01 AM"),
(
dayofyear(
caladddays(todatetime("01/01/2024 7:01 AM"), 0, "Default Calendar")
) - dayofyear(todatetime("01/01/2024 7:01 AM"))
),
datetime(2024,01,01)
)

I need the output to be 1/2/2024 7:01 AM instead I just get 1/2/2024.

5 replies

mathieud0001
November 8, 2023

What are you trying to do exactly?

manavik105
November 8, 2023

Hi Mathieu,  I have a scenario where if an expected SLA date&time falls on a non-working day, I need to get next working day value.

For example, I have my initial submitted date as 12/27/2023 2:01 PM PST and expected SLA date time based on some biz logic should be 1/2/2024 7:01 AM PST. I have used the below logic but somehow instead of getting the SLA date result for next year as 1/2/2024 7:01 AM PST, I am getting the SLA date result in the same year as 1/2/2023 7:01 AM PST.
Please note correct process calendars are used and Dec 30 2023,  Dec 31 2023 and Jan 1 2024 are all set as non-working day in the calendar.

Please help/advise on how I can update to get the correct value: ( I tried using workday but it returns just date and not datetime)

local!finalSLADateTime:
if(
calisworkday(1/1/2024 7:01 AM PST, local! Calendar),
1/1/2024 7:01 AM PST,
1/1/2024 7:01 AM PST + (dayofyear(caladddays(1/1/2024 7:01 AM PST, 0, local! Calendar)) - dayofyear(1/1/2024 7:01 AM PST))
),

stewart.burchell
November 8, 2023

As an approach treat the date and time as separate components. From your original value you an extract the date and time as separate values.

The apply your workday() function to the date component and then use the new date and old time components to generate a datetime value.

If you're still stuck ask.

annap0005
November 8, 2023

workday function returns date only.