cancel
Showing results for 
Search instead for 
Did you mean: 

DCL Question

 
SOLVED
Go to solution
Gilbert Pereira
Occasional Advisor

DCL Question

How can I use DCL to deternmine the current Thursday is which week number of the month?
5 REPLIES 5
Homer Shoemaker
Frequent Advisor

Re: DCL Question

You want to know if it is the first, second, third, fourth, or fifth Thursday of the month, correct?
Gilbert Pereira
Occasional Advisor

Re: DCL Question

Yes that is correct
Hein van den Heuvel
Honored Contributor

Re: DCL Question

Just do a quick loop subtracting weeks (7 days) untill teh month changes:

$ week = 0
$ this_month = f$cvtime(,,"MONTH")
$loop:
$ week = week + 1
$ days = week * 7
$ if this_month.eqs.f$cvtime("-''days'-",,"MONTH") then goto loop
$ write sys$output "Today is ", f$cvtime(,,"WEEKDAY"), " number : ", week
$ exit

hth,
Hein.


Jess Goodman
Esteemed Contributor
Solution

Re: DCL Question

How about something simple like:

$ day = f$cvtime(,,"DAY")
$ week = (day-1)/7 + 1

Which returns the week number for the current day. If you want the week number for the upcoming Thursday if today is not Thurdsay then just add a loop.

$ I = -1
$LP:
$ I = I+1
$ DATE = F$CVTIME("+''I'-","ABSOLUTE","DATE")
$ IF F$CVTIME(DATE,,"WEEKDAY").NES."Thursday" THEN -
$ GOTO LP
$ DAY = F$CVTIME(DATE,,"DAY")
$ WEEK = (DAY-1)/7 + 1
I have one, but it's personal.
Hein van den Heuvel
Honored Contributor

Re: DCL Question

Oops, I was thinking of something more elaborate, counting up or down to deal with months.

if it is Thursday, then current Thursday is of course simply

write sys$output f$cvtime(,,"DAY")+6)/7

The "next Thursday" is:

$ days_till_next_thursday = f$loc(f$ext(0,2,f$cvt(,,"WEEKDAY")),"xxWeTuMoSuSaFrTu")/2
$ write sys$output "Next Thursday is Thursday number : ", -
(6+f$cvt("+''days_till_next_thursday'-",,"DAY"))/7
Next Thursday is Thursday number : 3

Drop the "xx" depending on how you want to deal with cotay being a Thursday or not.

Hein.