Forum Academy Marketplace Showcase Pricing Features

Not so common date calculation

Hi all,

I need a calculation that I have never had to do and struggling to work it out, help would be greatly appreciated.

I have 4 separate dates and I need to automatically calculate the number of days between the latest date of 3 dates and the 4th date. See diagram for example.

I could probably achieve this by using a fair few conditions but I was wondering if there was a calculation that could take care of it.

Thanks in advance.

Cheers
Craig

It’s simple (unless I’m misunderstanding what you’re trying to do)…

Just sort the first 3 dates in order, and subtract last date from the 4th…

Or is there more to your question?..

1 Like

Hi Adam, thanks for your reply. These are 3 separate input fields for one thing so they are not in a list.

you can turn them into a list

have a state: list of dates. either create this on the page or group (click group and click i top right on black popup)

for each input have workflow: if inputs value is changed:
update the state to be input As date plus item input Bs date plus item input Cs date: ordered by date.

then in last step take 1st date and subtract last date as adam noted.

3 Likes

Just make them into a list, sort them, and deduct the last one from the fourth date.

2 Likes

Thank you for your help. I have tried what you have suggested but I don’t have the option to add the date to the list in the state.

I have added a workflow on the date picker to add the date pickers value to the state and it doesn’t allow it. There is no option for ‘set list’ either so not sure what is happening. Would you know what the issue could be?

image

Thanks for your help Adam

You need to set the custom state value to it’s existing value: plus item: This Date/time Picker’s value.

1 Like

Hi Adam,
I won’t lie, I have no idea how to do this, I cannot seem to find that option. The state doesn’t have a value as it won’t let me add a date?

image

1 Like

That’s great, thanks Adam, all working well now.

1 Like

Hi Adam, I have ran into another issue with this. When I refresh the page, the calculation result changes to a negative number and I am guessing this is because the custom state is temporary, is there a way to do a permanent calculation that stays correct after refreshing the page? Thanks in advance

If you want to do anything permanent you’ll have to store the data in the database (or elsewhere) - either the list of dates, or the calculated difference, depending on exactly what you’re trying to do.

1 Like

Thanks Adam, I think I will have to store the list of dates in the DB. Appreciate all your help.

Hi Adam, if I want to set an ‘update on change’ action to a date picker to update a list of dates from 3 different date pickers at the same time, I am guessing the only way to do this would be to clear the list first in an action before adding the new dates? I assume you can’t do ‘set list’ from 3 different date pickers? Am I assuming correct? Would ‘clear list’ first be the best way do you think?

Update, I have it working the way I mention above but I am not sure if this is the most efficient way of doing it.