Page 1 of 1

How to compute the week of the month

Posted: Fri Sep 16, 2005 10:31 am
by rob1
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

Posted: Fri Sep 16, 2005 10:51 am
by Sainath.Srinivasan
Search the forum. There are quite a few routines similar to your requirement.

Try using IConv.

(YourDate - FirstDateOfTheYear) / 7

You can deduce the first day of the week and adjust current week no.

Posted: Fri Sep 16, 2005 12:32 pm
by kumar_s
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

Posted: Fri Sep 16, 2005 4:28 pm
by ray.wurlod
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.