Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Calc last friday of month

by poolpi (Hermit)
on Feb 03, 2009 at 09:03 UTC ( #740926=note: print w/ replies, xml ) Need Help??


in reply to Calc last friday of month

Some examples :

#!/usr/bin/perl use strict; use warnings; use DateTime; my $dt = DateTime->last_day_of_month( year => 2009, month => 2 ); while ( $dt->mday() >= 1 and $dt->month == 2 ) { $dt->subtract( days => 1 ); print "Last Friday of February: ", $dt->ymd, "\n" and last if $dt->day_of_week == 5; } my $dt1 = DateTime->new( year => 2009, month => 1, day => 1 ); while (1) { $dt1->add( days => 1 ); print "First Monday of January: ", $dt1->ymd, "\n" and last if $dt1->day_of_week == 1; }


hth,
PooLpi

'Ebry haffa hoe hab im tik a bush'. Jamaican proverb


Comment on Re: Calc last friday of month
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2015-07-04 03:48 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 (57 votes), past polls