Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Split date range into 3 equal parts

by tobyink (Abbot)
on Dec 08, 2011 at 09:37 UTC ( #942380=note: print w/ replies, xml ) Need Help??

in reply to Split date range into 3 equal parts

Don't know about Date::Calc, but using DateTime...

use DateTimeX::Auto 0.003 qw/:auto/; my $from = '2010-06-01'; my $to = '2011-01-01'; my $diff = $to->delta_days($from)->in_units('days'); my $mid_date_1 = $from->clone->add(days => $diff/3); my $mid_date_2 = $to->clone->subtract(days => $diff/3); print <<OUT; from: $from mid 1: $mid_date_1 mid 2: $mid_date_2 to: $to OUT

UPDATE: Just released 0.003 of DateTimeX::Auto because the script above was crashing on add and subtract.

Comment on Re: Split date range into 3 equal parts
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://942380]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2015-11-30 09:28 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (769 votes), past polls