Routine Help

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
paddu
Premium Member
Premium Member
Posts: 232
Joined: Tue Feb 22, 2005 11:14 am
Location: California

Routine Help

Post by paddu »

I need to identify "first Monday of the Month" .

Found below post very helpful

http://dsxchange.com/viewtopic.php?t=10 ... 2774003db1



DSguru2B - Your post was helpful . Your routine worked for me only when i removed the UPCASE out of the variable DayToFind.

Routine:

InDate = Iconv(Trim(Arg1),"DYMD")
DayToFind = (Trim(Arg2))
DayByName = ''
DayByNum= ''

DayByName = Oconv(InDate,"DWA")
DayByNum = Oconv(InDate,"D D")


If (DayByName = DayToFind AND DayByNum < 8 )
Then
Ans = @TRUE
END
Else
Ans = @FALSE
End



Please let me know if my understanding is wrong.

Appreciate your suggestions.
Thanks
Paddu
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Identify the first day of the month. Lots of ways to do this - for example look at the MONTH.FIRST Transform.

Determine the day of the week of that day. Again, lots of ways to do this, but Mod(TheDate, 7) is probably the most efficient. 0 is Sunday, 6 is Saturday.

Add the right number of days to the (internal format of) the date and you have the date of the first Monday of the month.

Make an attempt - if you can't get it to work post your code and we'll constructively criticize it.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
paddu
Premium Member
Premium Member
Posts: 232
Joined: Tue Feb 22, 2005 11:14 am
Location: California

Post by paddu »

Ray,

Thanks for your quick response.

I need to check if the current date is first monday of the month in the job sequence . If true then start rest of the sequences else exit and send notification.

I am able to achieve using the routine DSguru2B posted.

If i understood your post correctly, you are suggesting to create a routine using the code of MONTH.FIRST transform and change it to achieve first monday of the month.

I will surely try and post my work .

Thanks
Paddu
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

Oconv(Date(), "D-YM[4,2]") : "-01"
yields the date of the first of the month. That should get you going.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
paddu
Premium Member
Premium Member
Posts: 232
Joined: Tue Feb 22, 2005 11:14 am
Location: California

Post by paddu »

Really !!!!, Let me try this tomorrow .
Not at desk right now :)
paddu
Premium Member
Premium Member
Posts: 232
Joined: Tue Feb 22, 2005 11:14 am
Location: California

Post by paddu »

ray.wurlod wrote:

Code: Select all

Oconv(Date(), "D-YM[4,2]") : "-01"
yields the date of the first of the month. That should get you going.

Ray,

I not trying to achieve date of first of the month from the current date.
Sorry i did not look into your post indetail before.

I am trying to see if the GIVEN_DATE (could be Current date ) is First Monday of the Month .

Thanks
Paddu
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

If your date in question is within the first 7 days of its month (day number is 1 thru 7) and the day of the week of your date is Monday, then logic would dictate that your date is the first Monday of its month.

If this is not right for your situation, then you need to clarify as I see two different requirements stated by you. If your processing requires you to confirm if a given date just happens to be the first Monday of its month, then my description above fits. If your processing requires you to confirm if a given date just happens to be the first Monday of the CURRENT month, that's a different scenario. Please clarify.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
paddu
Premium Member
Premium Member
Posts: 232
Joined: Tue Feb 22, 2005 11:14 am
Location: California

Post by paddu »

kcbland wrote:If your date in question is within the first 7 days of its month (day number is 1 thru 7) and the day of the week of your date is Monday, then logic would dictate that your date is the first Monday of its month.

If this is not right for your situation, then you need to clarify as I see two different requirements stated by you. If your processing requires you to confirm if a given date just happens to be the first Monday of its month, then my description above fits. If your processing requires you to confirm if a given date just happens to be the first Monday of the CURRENT month, that's a different scenario. Please clarify.
My requirement needs to confirm if a given date just happens to be the first Monday of the CURRENT month in the job sequence to start rest of the sequences else exit the sequence.

Which i am able to achieve with the routine mentioned in my first post.

I was just trying the logic which ray mentioned in this thread.

Anyways my original post was to make sure i am not going wrong anywhere .
since my issue is resolved on my end , i better mark this thread resolved .

I hope this will make GURUS to focus on other posts.

Thanks
paddu
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Oconv(InLink.GivenDate, "D-YM[4,2]") : "-01" is the first day of its month if GivenDate is in internal format. If it is not, apply an approriate Iconv() to GivenDate within the Oconv() function.

The function I have already given is the first day of the current month.

The rest is arithmetic.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply