Routine Help
Moderators: chulett, rschirm, roy
Routine Help
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
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
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
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
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
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Code: Select all
Oconv(Date(), "D-YM[4,2]") : "-01"
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.
ray.wurlod wrote:yields the date of the first of the month. That should get you going.Code: Select all
Oconv(Date(), "D-YM[4,2]") : "-01"
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
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.
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
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
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.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.
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
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.