Week Number in Year

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
garthmac
Charter Member
Charter Member
Posts: 55
Joined: Tue Oct 21, 2003 9:17 am
Location: UK

Week Number in Year

Post by garthmac »

Hi, is there an easy way to obtain the week number in year using Oconv (1 to 52)? (I know that I can use Oconv(Arg1, "DW") to get the day of the week as a number). I could probably work this out using stage variables and sequence numbers, but I was just wondering if this was possible.

Thanks
Garth
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Week conversion is done taking partial week into consideration.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Garthmac,

I think that there are a number of different methods of computing the calendar week. I would start off with the following:

Code: Select all

INT(OCONV({InternalDate},"DJ")/7)+1
This would be CW 1 for days 1 through 6 of the year, 2 for 7 through 13 and so on. Modify to your specific CW requirements at will :?
garthmac
Charter Member
Charter Member
Posts: 55
Joined: Tue Oct 21, 2003 9:17 am
Location: UK

Post by garthmac »

Thanks Arnd
Garth
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Garthmac,

I just remember doing this once and it wasn't the correct formula (it was in Germany and I recall looking up a DIN norm for the calendar week; something to do with the number of days in the first week of the year changing the start date...)
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Maybe for first week no falling fully on either past or present year.
elavenil
Premium Member
Premium Member
Posts: 467
Joined: Thu Jan 31, 2002 10:20 pm
Location: Singapore

Post by elavenil »

If you are using transformer, WEEK.TAG can be used to find out week number from the date.

HTWH.

Regards
Saravanan
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The business rule is documented in the Transform or the Routine that it invokes. (It's in the Code of the Routine, to explain why the particular algorithm used was chosen.)
This is one of the advantages of documentation. :wink:
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
garthmac
Charter Member
Charter Member
Posts: 55
Joined: Tue Oct 21, 2003 9:17 am
Location: UK

Post by garthmac »

Thanks everyone, I hadn't used WEEK.TAG before :)
Garth
Post Reply