Le forum (ô combien francophone) des utilisateurs de Powerbuilder.


Bonjour,
quelqu'un aurait t-il développé la formule sur les mois industriels ?
c'est a dire : Le mois industriel est défini par le dernier mercredi de chaque mois, et fini le dimanche.
Hors ligne














Bonjour, tu cherches à calculer quoi exactement ?
Hors ligne


Bah je pense que du coup je vais me débrouiller mais : Exemple :
Le calendrier industriel : on cherche le dernier mercredi de chaque mois, et le mois se termine le dimanche suivant.
Janvier 2011 le mois se termine : le 30 janvier
Février 2011 le mois se termine : le 27 février
Mars 2011 le mois se termine le 3 avril
Avril 2011 le mois se termine le le 1 mai
Mai 2011 le mois se termine le 29 mai....etc
il faut être un peu tordu...;)
Hors ligne
>sub get_ind_month_end{ my $d = RelativeDate(Date( shift(@_), shift(@_) + 1, 1 ), -1); #Lastday of month
while(DayNumber($d)!=4){
$d=RelativeDate($d,-1);
}
return RelativeDate( $d, 4 );
}
>get_ind_month_end(2011,1)
2011-01-30
>get_ind_month_end(2011,2)
2011-02-27
>get_ind_month_end(2011,3)
2011-04-03
>get_ind_month_end(2011,4)
2011-05-01
>get_ind_month_end(2011,5)
2011-05-29
>get_ind_month_end(2011,6)
2011-07-03
>get_ind_month_end(2011,7)
2011-07-31
>get_ind_month_end(2011,8)
2011-09-04
désolé, c'est du pseudo pb mais ca devrait faire l'affaire puisque çà utilise la PBVM...
Hors ligne
arf bug du mois 12...
>sub get_ind_month_end{ my ($year,$month) = @_;
my $d = RelativeDate( Date( $year + ($month==12?1:0), $month==12?1:($month+1), 1), -1);
while(DayNumber($d)!=4){
$d=RelativeDate($d,-1);
}
return RelativeDate( $d, 4 );
}
>join $/, map{ get_ind_month_end(2011,$_) } 1..12
2011-01-30
2011-02-27
2011-04-03
2011-05-01
2011-05-29
2011-07-03
2011-07-31
2011-09-04
2011-10-02
2011-10-30
2011-12-04
2012-01-01
>
Hors ligne


Un grand Merci, je teste tout ça et je te dis !!!!
Hors ligne