Change duration to number value

I need help extracting the number of days from a duration value.

Iโ€™m using this formula

(TODAY()) - [Mod Start]
(Mod Start is a past date)

The expression give me a duration value (โ€œ1995.00:00:00โ€).
Iโ€™d like to give me the number of days value (โ€œ1995โ€)

Any help would be appreciated

Solved Solved
1 7 3,961
1 ACCEPTED SOLUTION

Actually, nope. @Marc_Dillon I stand corrected. It was buried in the article, but I found it.

HOUR(TODAY() - [Mod Start]) / 24

This just gives me the days

So Iโ€™m good with this one. thanks

View solution in original post

7 REPLIES 7

Posted a bit too hastily before, then went to test my reply (test after the reply, probably the wrong orderโ€ฆ).
I donโ€™t understand how your duration value has โ€œ1995.โ€ in the front.

This article should still help. There are some rather complicated formulas at the bottom for getting years/months/days out of a duration

the โ€œ1995โ€ is the number of days. the value seems to be in DD:HH:MM:SS format. the values are two whole dates, so I just want the days.

Appsheet, frustratingly, doesnโ€™t provide a simple way to do this.

Iโ€™ll take a look at the article and let you know.

Addendeum: Iโ€™ve actually already saw that article before I typed my request. Nothing in there about how to extract the days from the duration. So I need someone help me with a custom expression.

Actually, nope. @Marc_Dillon I stand corrected. It was buried in the article, but I found it.

HOUR(TODAY() - [Mod Start]) / 24

This just gives me the days

So Iโ€™m good with this one. thanks

Oh, ok cool. Thatโ€™s exactly what I typed in my first (deleted) respond, but I then tested it with the duration value you provided and it gave me 0. Hmmm

I was getting those too when I converted today to a number

(NUMBER((TODAY()) - [Mod Start]) / 24)

seems keeping it as a duration value did the trick. Itโ€™s not obvious tho. But it worked so I guess thereโ€™s that

Hi!  I'm just coming across this because I had a similar question and wound up doing the following:

 

ceiling(([Later datetime]-[Earlier datetime])/decimal(24))

 

I did it this way because I wanted any part of a 24-hour period to be considered one day.  Without the "decimal" and the "ceiling," anything under 24 hours (that is, any part of a day) was discarded.  There's probably a better way but this is what I came up with.

After a bit more consideration, I changed my expression as follows:

hour(date([Later datetime])-date([Earlier datetime]))/24+1

This way, the expression counts the number of calendar days.  So, even if the period is just a few hours, if it starts late in one day and ends in the early morning hours the next, the result would be 2, which is what I wanted.

Top Labels in this Space