Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Calc last friday of month

by poolpi (Hermit)
on Feb 03, 2009 at 09:03 UTC ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-03-29 13:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found