Page 1 of 1

Week Number in Year

Posted: Tue Jul 19, 2005 7:58 am
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

Posted: Tue Jul 19, 2005 7:59 am
by Sainath.Srinivasan
Week conversion is done taking partial week into consideration.

Posted: Tue Jul 19, 2005 8:25 am
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 :?

Posted: Tue Jul 19, 2005 8:57 am
by garthmac
Thanks Arnd

Posted: Tue Jul 19, 2005 9:11 am
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...)

Posted: Tue Jul 19, 2005 9:16 am
by Sainath.Srinivasan
Maybe for first week no falling fully on either past or present year.

Posted: Tue Jul 19, 2005 9:38 am
by elavenil
If you are using transformer, WEEK.TAG can be used to find out week number from the date.

HTWH.

Regards
Saravanan

Posted: Tue Jul 19, 2005 3:23 pm
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:

Posted: Wed Jul 20, 2005 6:27 am
by garthmac
Thanks everyone, I hadn't used WEEK.TAG before :)