Hi Todd, Todd Goldenbaum wrote: > > I'm curious now though, what >is< $duration->days used for, > if not for expressing the length in days of a $duration? > >From the Docs:
These methods return numbers indicating how many of the given unit the object represents, after having taken away larger units. The key here is "after having taken away larger units" using your example you were expecting the days unit to be set to 18 however, that can also be expressed as 2 weeks and 4 days. Which is what DateTime is doing: use strict; use warnings; use DateTime; use DateTime::Format::MySql; my $start_date = DateTime::Format::MySQL->parse_date( '2005-01-05' ); my $end_date = DateTime::Format::MySQL->parse_date( '2005-01-23' ); my $dur = $start_date->delta_days( $end_date ); print "Number of weeks is:",$dur->weeks ,"\n"; print "Number of days is:", $dur->days; prints F:\scripts>my.pl Number of weeks is:2 Number of days is:4 F:\scripts> So what is needed is a way to tell DateTime to convert all units to just one, in your case days. Hence the in_units method needs to be used. I hope this helps. Thanks Ron Hill