Third sunday in the month - VMS
This is a discussion on Third sunday in the month - VMS ; On Wed, 29 Aug 2007 12:57:44 -0700, apogeusistemas@gmail.com wrote:
>Hi:
>Iīm looking for a command procedure to send a operatorīs message
>if the day is the third sunday in the month.
>Can you help me ?
>Thank you.
if you ...
-
Re: Third sunday in the month
On Wed, 29 Aug 2007 12:57:44 -0700, apogeusistemas@gmail.com wrote:
>Hi:
>Iīm looking for a command procedure to send a operatorīs message
>if the day is the third sunday in the month.
>Can you help me ?
>Thank you.
if you are able to use perl, consider using installing
the Date::Calc modules
eg
http://search.cpan.org/~tchatzi/Date-Calc/Calc.pod
http://search.cpan.org/~stbey/Date-Calc-5.4/Calc.pod
here's an example to figure the 3rd Friday.
use Date::Calc qw( Today Add_Delta_Days Nth_Weekday_of_Month_Year );
($year,$month,$day) = Today();
# P3: 5 = Friday
# P4: 3 = 3rd occurance of that day of week
($year0,$month0,$day0) = Nth_Weekday_of_Month_Year($year,$month,5,3);
# Saturday following
($year1,$month1,$day1) = Add_Delta_Days($year0,$month0,$day0,1 );
# Sunday following
($year2,$month2,$day2) = Add_Delta_Days($year0,$month0,$day0,2 );
$today = sprintf( "%04u/%02u/%02u",$year, $month, $day );
$ThirdFri_plus_0 = sprintf( "%04u/%02u/%02u",$year0,$month0,$day0);
$ThirdFri_plus_1 = sprintf( "%04u/%02u/%02u",$year1,$month1,$day1);
$ThirdFri_plus_2 = sprintf( "%04u/%02u/%02u",$year2,$month2,$day2);
printf( "Today: %s\n",$today );
printf( "3rd Fri+0: %s\n",$ThirdFri_plus_0 );
printf( "3rd Fri+1: %s\n",$ThirdFri_plus_1 );
printf( "3rd Fri+2: %s\n",$ThirdFri_plus_2 );
-
Re: Third sunday in the month
apogeusistemas@gmail.com wrote in news:1188427622.398539.57180@
22g2000hsm.googlegroups.com:
[snip..]
> $ set nover
> $ hour="''F$EXTRACT(12,2, F$TIME())'"
> $ day=F$CVTIME(,,"day")
> $ week=F$CVTIME(,,"weekday")
> $ if ((week .eqs. "Sunday") .and. (day .gt. "14") .and. (day .lt.
> "23") .and. (hour .eq. "12")) then goto dispara
> $exit
> $dispara:
> $ mail/subj=" >>> Restarte o Server <<< " sys
> $login:restart_server.txt "smtp%""schwarzt@aaaaaaa.com.br"""
> $exit
>
> Thanks a lot for your examples !
>
>
Forgetting the calculation of the third Sunday of the month, is this a
reminder to restart a VMS system? If the answer is yes, you certainly must
have some other question that needs to be answered.
-
Re: Third sunday in the month
On 31 ago, 22:45, Tad Winters
wrote:
> apogeusiste...@gmail.com wrote in news:1188427622.398539.57180@
> 22g2000hsm.googlegroups.com:
>
> [snip..]
>
> > $ set nover
> > $ hour="''F$EXTRACT(12,2, F$TIME())'"
> > $ day=F$CVTIME(,,"day")
> > $ week=F$CVTIME(,,"weekday")
> > $ if ((week .eqs. "Sunday") .and. (day .gt. "14") .and. (day .lt.
> > "23") .and. (hour .eq. "12")) then goto dispara
> > $exit
> > $dispara:
> > $ mail/subj=" >>> Restarte o Server <<< " sys
> > $login:restart_server.txt "smtp%""schwa...@aaaaaaa.com.br"""
> > $exit
>
> > Thanks a lot for your examples !
>
> Forgetting the calculation of the third Sunday of the month, is this a
> reminder to restart a VMS system? If the answer is yes, you certainly must
> have some other question that needs to be answered.
I need restart a W2K3 sql server every 3rd Sunday.
Task passed by a Windows administrator...
-
Re: Third sunday in the month
On Aug 30, 8:38 am, VAXman- @SendSpamHere.ORG wrote:
> In article <1188437058.314136.41...@57g2000hsv.googlegroups.co m>, apogeusiste...@gmail.com writes:
>
[...]
> >I made this change:
>
> >$ hour=3D"''F$EXTRACT(12,4, F$TIME())'"
> >$ day=3DF$CVTIME(,,"day")
> >$ week=3DF$CVTIME(,,"weekday")
> >$ if ((week .eqs. "Sunday") .and. (day .gt. 14) .and. (day .lt.
> >22) .and. (hour .eq. "12:0")) then goto dispara
>
> >and I=B4ll receive only 2 alerts (maybe only 1)
>
> You can avoid the two date compares with this BTW:
>
> ((day .gt. 14) .and. (day .lt.22)) == ((day-1)/7 .eq. 2)
What's the advantage of this?
This is DCL, no? Why the double equals sign?
>
> --
> VAXman- A Bored Certified VMS Kernel Mode Hacker VAXman(at)TMESIS(dot)COM
>
[...]
AEF
-
Re: Third sunday in the month
apogeusistemas@gmail.com wrote:
> [...snip...]
>
> I need restart a W2K3 sql server every 3rd Sunday.
> Task passed by a Windows administrator...
Every *3rd* *Sunday* ? I thought you had to restart them
every day ;-)
-
Re: Third sunday in the month
In article <1188653375.860361.214550@k79g2000hse.googlegroups. com>, AEF writes:
>
>
>On Aug 30, 8:38 am, VAXman- @SendSpamHere.ORG wrote:
>> In article <1188437058.314136.41...@57g2000hsv.googlegroups.co m>, apogeusiste...@gmail.com writes:
>>
>[...]
>> >I made this change:
>>
>> >$ hour=3D"''F$EXTRACT(12,4, F$TIME())'"
>> >$ day=3DF$CVTIME(,,"day")
>> >$ week=3DF$CVTIME(,,"weekday")
>> >$ if ((week .eqs. "Sunday") .and. (day .gt. 14) .and. (day .lt.
>> >22) .and. (hour .eq. "12:0")) then goto dispara
>>
>> >and I=B4ll receive only 2 alerts (maybe only 1)
>>
>> You can avoid the two date compares with this BTW:
>>
>> ((day .gt. 14) .and. (day .lt.22)) == ((day-1)/7 .eq. 2)
>
>What's the advantage of this?
>
>This is DCL, no? Why the double equals sign?
Doh! The expression: ((day .gt. 14) .and. (day .lt.22)) can be expressed as
or is equivalent to: ((day-1)/7 .eq. 2) It has nothing to do with DCL per
se.
Normalizing the day to 0 (day-1) allow one to check for the week using
0,1,2,3... for 1st, 2nd, 3rd, 4th week.
--
VAXman- A Bored Certified VMS Kernel Mode Hacker VAXman(at)TMESIS(dot)COM
"Well my son, life is like a beanstalk, isn't it?"
http://tmesis.com/drat.html