Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Quarter Dates

by sflitman (Hermit)
on Jun 09, 2010 at 06:24 UTC ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (7)
As of 2024-04-18 17:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found