Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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 making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2015-07-02 05:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (29 votes), past polls