Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Quarter Dates

by sflitman (Hermit)
on Jun 09, 2010 at 06:24 UTC ( #843815=note: print w/ replies, xml ) Need Help??


in reply to Quarter Dates

Here is a solution:

. . . # Now loop for beginning qtr and ending qtr while (Date_to_Days(@x) < Date_to_Days(@y)) { my @qtr_end_date=Add_Delta_YMD(@x, 0,3,-1); my $diff=Date_to_Days(@qtr_end_date)-Date_to_Days(@e_dt); print "DIFF $diff\n"; if (abs($diff)<60) { @qtr_end_date=@e_dt; } printf("%4d-%02d-%02d\t%4d-%02d-%02d\t%sQ%01d\n", @x, @qtr_end_date, substr($x[0],2,2), $qtr); @x = Add_Delta_YMD(@x, 0,3,0); # roll over quarter to 1, beyond 4 $qtr++; $qtr = $qtr > 4 ? 1 : $qtr; } . . .
This is tested for your two cases. I am curious why you would want output which truncates the last quarter?

HTH,
SSF


Comment on Re: Quarter Dates
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (13)
As of 2014-12-18 21:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (66 votes), past polls