Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://942380]
help
Chatterbox?
[Discipulus]: Mr haukex from Germany! thanks a lot to the other parteciapant our dear Mr afoken.. ;=)
[Discipulus]: no, seriously thanks both, i missed 'scientist' and 'floating point' and the resarche was imposible..
Discipulus go to his cell to bookmark this
[haukex]: Well to be honest I just did a super search for "every should know floating" ;-)
[Discipulus]: floating was the keyword and.. to use supersearch is plus sign not a (plus) sin

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2017-06-26 20:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (594 votes). Check out past polls.