Calculating days between $StartDate and $EndDate

Since @satikusala referred to it, just a question @mwra. How would this code be different if one wanted hours and minutes rather than days? (I mean, part of this is obvious, I guess, specifying hours and minutes, but how to do that in this code?) But also, the duration code Michael referred to above is working well for me and is simpler. What’s the advantage of the more complex variable specification?

It’s just a question of exactly what you want to measure.

How many days are between $StartDate and $EndDate? We might have different answers for different people:

  • 1.872 for Amy, who likes fractional days
  • 2 days for Ben, who rounds up
  • 1 day for Charlie, because it’s less than 2
  • 1 day, 20 hours, 56 minutes for Diana, who likes Babylonian units

If you want to work in hours and minutes, the Interval type gives you some convenient extractors and formatters.

1 Like

I think @eastgate has covered this, do ask if not.