# Re: How to configure a conditional, combined DATETIME_DIFF formula

Solved
178 1
cancel
Showing results for
Did you mean:
6 - Interface Innovator

Hello,

What would be the easiest way to configure a formula that combines all of these?

• IF({Request Type}=‘New’, DATETIME_DIFF({DCML Issue Date Lookup},RequestDate,‘days’)

• IF({Request Type}=‘Major Update (Procedure Change)’, DATETIME_DIFF({DCML Rev Date Lookup},RequestDate,‘days’)

• IF({Request Type}=‘Minor Update (Formatting, Spelling, Grammar, etc.)’,DATETIME_DIFF({DCML NCC Date},RequestDate,‘days’)

I tried a formula that combined the first two, and the system accepts it, but it doesn’t return anything.

Thanks :slightly_smiling_face:

1 Solution

Accepted Solutions
16 - Uranus

I would use a combination of SWITCH() and IF() statements for this:

``````SWITCH(
{Request Type},
"New", IF(
AND({DCML Issue Date Lookup}, {RequestDate}),
DATETIME_DIFF({DCML Issue Date Lookup}, {RequestDate}, "days")
),
"Major Update (Procedure Change)", IF(
AND({DCML Rev Date Lookup}, {RequestDate}),
DATETIME_DIFF({DCML Rev Date Lookup}, {RequestDate}, "days")
),
"Minor Update (Formatting, Spelling, Grammar, etc.)", IF(
AND({DCML NCC Date}, {RequestDate}),
DATETIME_DIFF({DCML NCC Date}, {RequestDate}, "days")
),
"Incomplete / Closed", IF(
)
)
``````

The above formula will test the `{Request Type}` and depending on its value output the relevant difference between two dates only if both those date fields have a value.

2 Replies 2
16 - Uranus

I would use a combination of SWITCH() and IF() statements for this:

``````SWITCH(
{Request Type},
"New", IF(
AND({DCML Issue Date Lookup}, {RequestDate}),
DATETIME_DIFF({DCML Issue Date Lookup}, {RequestDate}, "days")
),
"Major Update (Procedure Change)", IF(
AND({DCML Rev Date Lookup}, {RequestDate}),
DATETIME_DIFF({DCML Rev Date Lookup}, {RequestDate}, "days")
),
"Minor Update (Formatting, Spelling, Grammar, etc.)", IF(
AND({DCML NCC Date}, {RequestDate}),
DATETIME_DIFF({DCML NCC Date}, {RequestDate}, "days")
),
"Incomplete / Closed", IF(
The above formula will test the `{Request Type}` and depending on its value output the relevant difference between two dates only if both those date fields have a value.