in reply to I can't subtract one DateTime object from another to get a DateTime::Duration in days

you are not showing any code to reproduce the problem, the snippet is just copied from the pod.

My best guess is that you are requesting "days" from a duration which has "no fixed conversion rate" for days.

From the docs, just a paragraph after the code you posted ...

The only conversions possible are:

years <=> months

weeks <=> days

hours <=> minutes

seconds <=> nanoseconds

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

  • Comment on Re: I can't subtract one DateTime objects from each other to get a DateTime::Duration in days

Replies are listed 'Best First'.
Re^2: I can't subtract one DateTime objects from each other to get a DateTime::Duration in days
by Cody Fendant (Hermit) on May 10, 2021 at 23:36 UTC

    I have updated the post to make it more clear what's happening.

    One DateTime object, with a specific date and time, is being subtracted from another specific DateTime object.

      > I have updated the post to make it more clear what's happening.

      no you haven't, please see SSCCE for the next time.

      update

      FWIW: your approach is still wrong and will only sometimes produce correct results.

      See 1nickt's reply with ->delta_days for the correct solution

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery