Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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 taking refuge in the Monastery: (12)
As of 2014-08-21 20:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (143 votes), past polls