Number of the week - Oconv code
Moderators: chulett, rschirm, roy
Number of the week - Oconv code
Hi there folks,
Can anyone tell me what the conversion code is to get the number of the week in a year corresponding to a supplied internal date using OCONV ?
Can anyone tell me what the conversion code is to get the number of the week in a year corresponding to a supplied internal date using OCONV ?
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
There isn't one.
The reason is that the week number is determined by a business rule. On what day does a week start? How is week number 1 in a year defined (all weeks must have seven days, so "starts on Jan 1" is not a good rule).
Look at the Transform WEEK.TAG and the WeekTag routine that it calls. These document one business rule (from memory, week begins on a Monday, and week 1 is the first week that contains four calendar dates in that year).
The reason is that the week number is determined by a business rule. On what day does a week start? How is week number 1 in a year defined (all weeks must have seven days, so "starts on Jan 1" is not a good rule).
Look at the Transform WEEK.TAG and the WeekTag routine that it calls. These document one business rule (from memory, week begins on a Monday, and week 1 is the first week that contains four calendar dates in that year).
Last edited by ray.wurlod on Fri Feb 09, 2007 4:06 pm, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
No such conversion code but not hard to do it.
If going by calender weeks, you can do something like
If going by calender weeks, you can do something like
Code: Select all
INT(OCONV(InternalDate, "DJ")/7)
Last edited by DSguru2B on Fri Feb 09, 2007 4:07 pm, edited 1 time in total.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Yea. I read your post after hitting the reply button on my end. But if the OP needs the week of the year going by calender date and not a business date, my way should work . For other dates, more information is needed.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
On what day does a week start? How is week number 1 in a year defined (all weeks must have seven days, so "starts on Jan 1" is not a good rule).
Solution #1
Look at the Transform WEEK.TAG and the WeekTag routine that it calls. These document one business rule (from memory, week begins on a Monday, and week 1 is the first week that contains four calendar dates in that year).
Solution #2
Find a BA who thinks things through rather than taking the path of least resistance.
Solution #1
Look at the Transform WEEK.TAG and the WeekTag routine that it calls. These document one business rule (from memory, week begins on a Monday, and week 1 is the first week that contains four calendar dates in that year).
Solution #2
Find a BA who thinks things through rather than taking the path of least resistance.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Thanks Ray, solution 2 is out, doesn't look like anybody cares (but me) .......looking at solution 1ray.wurlod wrote:On what day does a week start? How is week number 1 in a year defined (all weeks must have seven days, so "starts on Jan 1" is not a good rule).
Solution #1
Look at the Transform WEEK.TAG and the WeekTag routine that it calls. These document one business rule (from memory, week begins on a Monday, and week 1 is the first week that contains four calendar dates in that year).
Solution #2
Find a BA who thinks things through rather than taking the path of least resistance.