Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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 having an uproarious good time at the Monastery: (11)
As of 2016-05-24 17:04 GMT
Find Nodes?
    Voting Booth?