'WEEK.TAG' with Sunday as start of week
Moderators: chulett, rschirm, roy
'WEEK.TAG' with Sunday as start of week
Dears,
I was wondering about how to customize the 'WEEK.TAG' and 'ConvertWeek' function to retrieve a week which starts with Sunday instead of Monday.
Regards.
I was wondering about how to customize the 'WEEK.TAG' and 'ConvertWeek' function to retrieve a week which starts with Sunday instead of Monday.
Regards.
Sorry, that was my mistake - I was thinking of Parallel functions and just now realized that you meant a server job. I'm sorry about that.
I would write my own routine and use 3 ICONV/OCONV calls:
Knowing what day of week your first day of the year was, and what day of the year you want to compute a calendar week for, you can perform your own calendar week calculations.
I would write my own routine and use 3 ICONV/OCONV calls:
Code: Select all
InternalDate = ICONV(InputDate,"D4/YMD[2,2,2]") ;** assuming that is your date string format
JulianDate = OCONV(InternalDate,"DJ")
FirstDayOfYear = OCONV(InternalDate-JulianDate+1,"DW")
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
ArndW, I've tried tried your routine and it gives the following output:
InternalDate, JulianDate , FirstDayOfYear , DayName , Date
14637, 27 , 3 , Sunday , 2008-01-27
14647, 37 , 3 , Wednesday , 2008-02-06
I don't know why the 'FirstDayOfYear' is always '3' for these records?
Ray, I'm not pretty handy with Basic, but I've tried to reassign the DayOfWeek values in WEEK.TAG to start from 0 to 6 as 0 is Sunday and 6 is Saturday, but it didn't work and it gives the same result as before.
Craig, I didn't find it unfortunately in my search
Regards.
InternalDate, JulianDate , FirstDayOfYear , DayName , Date
14637, 27 , 3 , Sunday , 2008-01-27
14647, 37 , 3 , Wednesday , 2008-02-06
I don't know why the 'FirstDayOfYear' is always '3' for these records?
Ray, I'm not pretty handy with Basic, but I've tried to reassign the DayOfWeek values in WEEK.TAG to start from 0 to 6 as 0 is Sunday and 6 is Saturday, but it didn't work and it gives the same result as before.
Craig, I didn't find it unfortunately in my search
![Sad :(](./images/smilies/icon_sad.gif)
Regards.
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
Sorry for not mentioning the details.
I tried to pass 'Date+1' as 'Sainath' suggested by doing this:
DateOne : OCONV(InternaltDate+1, 'D-YMD[4,2,2]') as stage variable
Calender Week : TAG.TO.WEEK(DateOne)
The problem always in the last week of year, which depends on the number of days at the lase week week in year. If number of days at last week < 4, it works fine. Otherwise, week number is even increased or decreased by one (i.e. week 53 instead of 52 or week 1 instead of 53,...)
PS : Nice one ArndW.
Regards & thanks for help.
I tried to pass 'Date+1' as 'Sainath' suggested by doing this:
DateOne : OCONV(InternaltDate+1, 'D-YMD[4,2,2]') as stage variable
Calender Week : TAG.TO.WEEK(DateOne)
The problem always in the last week of year, which depends on the number of days at the lase week week in year. If number of days at last week < 4, it works fine. Otherwise, week number is even increased or decreased by one (i.e. week 53 instead of 52 or week 1 instead of 53,...)
PS : Nice one ArndW.
Regards & thanks for help.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
All years have a 53rd week under the business rule that every week has exactly seven days. 365/7 = 52.14... and 366/7 = 52.28...
Maybe you need to specify your business rule more carefully.
Maybe you need to specify your business rule more carefully.
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.