0

# Countdown Date

Hi,

I have a problem with a formula

I would like to calculate how many months from today to a certain date

this as written but it does not give me any results.

let Countdown := round((today() - Fine) / 2592000000 * -1);

tnks

## 10replies

• szormpas
• 11 days ago
• Reported - view

Hi,

Can you try the following:

``````floor(number(today() - Fine) / 2629746000)
``````
• Andrea_Giorgi
• 11 days ago
• Reported - view

tnks. work it!

• szormpas
• 11 days ago
• Reported - view

Hi, I’m glad it works. Can you mark the post as answered?

• Fred
• 11 days ago
• Reported - view

You can also try:

``````let x := if year(Date) > year(today()) then
12 + month(Date)
else
month(Date)
end;
month(today()) - x
``````

It is not as short but a bit more understandable to those new to Ninox date fields.

• John_Halls
• 11 days ago
• Reported - view

I think this method will also give a more accurate result. 2629746000 is the number of milliseconds in a month but this must be a generalisation surely?

• Fred
• 11 days ago
• Reported - view

To be more accurate it would have to take into account multiple years:

``````let x := if year(Date) > year(today()) then
(12 * (year(Date)-year(today())) ) + month(Date)
else
month(Date)
end;
month(today()) - x``````
• John_Halls
• 10 days ago
• Reported - view

yes, of course. Good spot.

• szormpas
• 10 days ago
• Reported - view

Hi, you made me rethink this.

It is a matter of problem definition. Let's say that 'Date' is yesterday (31/07/2024 or 07/31/2024):

If we are interested in counting the changes in the calendar months between today and yesterday then the answer is (1) month based on your solution.

On the other hand, if we are interested in counting the duration of time in months then the answer is (0) month based on my solution (to be precise is one day).

which of the problems mentioned above are you trying to solve?

• Fred
• 10 days ago
• Reported - view

Just a thought process. 1 month is about 2.6 billion milliseconds. But what about February? 1 day is about 86 million milliseconds. So three days difference in Feburary is about 258 million milliseconds. So about 10% of the value of a month. But I guess it gets you close enough to measure the duration of time in months.

• szormpas
• 10 days ago
• Reported - view

the number of days in each month can range from 28 to 31 Days (accordingly the milliseconds).

To be more accurate, The Gregorian calendar has 4 months that are 30 days long and 7 months that are 31 days long. February is the only month that is 28 days long in common years and 29 days long in leap years.

That is the reason why we should somehow average the duration of each month if we want to express the time duration in months.

Finally, it depends on what we want to achieve and how accurate we want to be. Is it simply the difference of the month values for the dates, or is it more related to an actual span of time?

## Content aside

• Status Answered
• 10 days agoLast active
• 10Replies
• 82Views
• 4 Following