How could I compute the week of the month for a date.
The week #1 begins on the first day of the month and end on the first sunday .
If somebody has a routine, let me know it
How to compute the week of the month
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
Hi,
Another possible work around,
Assingh some variables for value for each day say sunday = 7 monday = 6, tuesday = 5....
Let the date to find be 16-09-2005
find the the first day of the month(01-09-2005) Thursday
subract the respective variable from the date,
i.e., 16 - 4 (Thrusday) = 12
find ceil(12/ 7)+1 = 3
IHTH
regards
kumar
Another possible work around,
Assingh some variables for value for each day say sunday = 7 monday = 6, tuesday = 5....
Let the date to find be 16-09-2005
find the the first day of the month(01-09-2005) Thursday
subract the respective variable from the date,
i.e., 16 - 4 (Thrusday) = 12
find ceil(12/ 7)+1 = 3
IHTH
regards
kumar
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Mod(DayNumber, 7) returns 0 for Sunday and 6 for Saturday where DayNumber is in DataStage internal format.
Applying that knowledge to the date you're testing and to the first day of the same month (see also MONTH.FIRST Transform) should give you an elegant solution.
Applying that knowledge to the date you're testing and to the first day of the same month (see also MONTH.FIRST Transform) should give you an elegant solution.
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.