Count deal cycle duration based on stage?

Count deal cycle duration based on stage?

Hi, Zoho community.

Trying to develop a custom function that will count the Overall Deal Cycle Duration but it will be stopped when a deal hit the Won/Closed Lost or On Pause stage.

So basically the principle here is:

IF Stage is not equal to Won, Closed Lost, or Keep In View than Compdata (NOW - deal created time)
IF Stage is Won, Closed Lost, or Keep In View pause the count.

Any chance somebody could help with this?