The total number of days before a date is reached (code)

Hi there.

I have a dates such as

18/12/2024

What I want to do is capture two different values in two other fields:

A) The number of days until that date is reached - changes dynamically (so that value will run down to 0 when 18/12/2024 is reached)

B) The number of days until that date is reached, at the time the record was added. So I can say that when that record was added to the system there were X days until the date was reached.

I saw that there was a getnetdays (from memory) or similar field that would not consider weekends. I’m therefore asking here for any help.

Thanks
GSH

Hi @GSH, you can use exactly what you mentioned: the netWorkDays() function in an Equation field.

Assuming you have Added date and Deadline date date fields:

You add a Days left from added equation field:

And a Days left from today equation field:

Both handle the case where the deadline date is earlier than either the added date or today’s date.

1 Like

Heroic, many thanks!

I don’t suppose you fancy doing a text field for those formulas?

You mean like this?:

Days left from added

{Added date} >= {Deadline date} ? 0 : networkDays({Added date}, {Deadline date})

Days left from today

currentDate() >= {Deadline date} ? 0 : networkDays(currentDate(), {Deadline date})
1 Like