Operating System - OpenVMS
1827990 Members
2180 Online
109973 Solutions
New Discussion

Calculate weeknumber with a DCL-script

 
SOLVED
Go to solution
geir_2
Super Advisor

Calculate weeknumber with a DCL-script

is it possible to use a simple DCL-script to calculate the actual weeknumber? 1-52 (53, some special events)

Maybe it's possibel to use daynumber in the year together with a modulo function?

Thanks
Geir

11 REPLIES 11
Marc Van den Broeck
Trusted Contributor

Re: Calculate weeknumber with a DCL-script

Geir,

use the lexical f$cvtime to get the weeknumber.

Rgds
Marc
geir_2
Super Advisor

Re: Calculate weeknumber with a DCL-script

Hi,

I have problem to find suitable arguments to calculate weeknumber. Myabe I have som trouble to see the correct argument??

geir
Ian Miller.
Honored Contributor

Re: Calculate weeknumber with a DCL-script

Does this do want you want?
WEEKNO = 1+ f$cvtime(,"ABSOLUTE","DAYOFYEAR")/7
____________________
Purely Personal Opinion
Kris Clippeleyr
Honored Contributor
Solution

Re: Calculate weeknumber with a DCL-script

Geir,
Got this (=attachment) a while back from the net (don't know where exactly).
According to the comments, the algorithm is by Rick McCarty.
It seems to do what you want.
Have fun,
Kris (aka Qkcl)
I'm gonna hit the highway like a battering ram on a silver-black phantom bike...
Paul Jerrom
Valued Contributor

Re: Calculate weeknumber with a DCL-script

Presumably the answer would depend on how you define the first week of the year. Ian's answer above would give Sunday 1st Jan-Saturday 6th Jan as week 1; the ISO answer says 1st Jan was week 52 of last year. Next year Ian's answer would be Monday 1st Jan-Sunday 6th Jan.
Other definitions of week 1 would be the week that contains Jan 1; the week that contains the first Monday of the year; or the first week that contains a majority of days in this year.
So probably best that you define in words what your definition of the first week of the year is, then doubtless someone will come up with a bit of DCL for you!

Have fun,

PJ
Have fun,

Peejay
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If it can't be done with a VT220, who needs it?
Jan van den Ende
Honored Contributor

Re: Calculate weeknumber with a DCL-script

Paul,

see the attachment by QKCL for the official ISO definition.
The week (monday though sunday) containing the first THURSDAY of the year is defined to be Week 01.
And if you wonder how they got to THAT definition: they probably were utterly drunk and at the same time using some illegal hallicinogens at the same time!

hth.

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Joseph Huber_1
Honored Contributor

Re: Calculate weeknumber with a DCL-script

Jan, no , they were just (too?) sober: the Thursday rule makes sure week 01 contains at least 1 working day.

(Although I admit it is true for western culture only, where Sat./Sunday is the weekend).
http://www.mpp.mpg.de/~huber
geir_2
Super Advisor

Re: Calculate weeknumber with a DCL-script

Hi,
Thanks to all. :-)
Martin Vorlaender
Honored Contributor

Re: Calculate weeknumber with a DCL-script

Jan,

the thursday rule is equivalent to "week containing at least 4 days" or "majority of days in the week".

cu,
Martin
Martin Vorlaender
Honored Contributor

Re: Calculate weeknumber with a DCL-script

Jan,

"week containing the first thursday" is equivalent to "first week containing at least 4 days" or "first week with a majority of days in the week".

cu,
Martin
Jan van den Ende
Honored Contributor

Re: Calculate weeknumber with a DCL-script

Martin,

ok, that explains it a bit better than the official text!

Tnx.

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.