View previous topic :: View next topic
|
Author |
Message |
cvasu03
New User
Joined: 23 Mar 2007 Posts: 9 Location: USA
|
|
|
|
I have coded the rexx program for date in the following way.
CURRDATE = SUBSTR(DATE(S),3,2) || SUBSTR(DATE(S),5,2) || SUBSTR(DATE(S),,7,2)
CURRYY = SUBSTR(DATE(S),3,2)
CURRYYYY = SUBSTR(DATE(S),1,4)
CURRMM = SUBSTR(DATE(S),5,2)
CURRDD = SUBSTR(DATE(S),7,2)
I want to check for the quarter end date. If the current month is > 3 and less than 6 then set the month to 03 and similarly for other quarters.
QTRENDDT = CURRYYYY || CURRMM
Do While (CURRMM \= 03 & CURRMM \= 06 & CURRMM \= 09 & CURRMM \= 12)
If (CURRMM = 03 | CURRMM = 06 | CURRMM = 09 | CURRMM = 12) Then
QTRENDDT = CURRYYYY || CURRMM
Else If (CURRMM = 01) Then
Do
QTRENDDT = CURRYYYY - 1 || 12
CURRMM = 12
End
Else If (CURRMM \= 01) Then
Do
CURRMM = CURRMM - 1
QTRENDDT = CURRYYYY || CURRMM
End
End
The logic is working fine. Only problem is with leading zeroes in month.
The month it is giving is 3 instead of 03 after concatenation.
Result is
QTRENDDT = 20093
I want the result to be 200903. I have tried the RIGHT function but it is ABENDING. May be i have not used it correct way. Please help!
Thanks |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
odd, never happened to me
post the culprit statement exactly as You have written it
also
Quote: |
I want to check for the quarter end date. If the current month is > 3 and less than 6 then set the month to 03 and similarly for other quarters.
|
please clarify ...
usually
Code: |
1-3 quarter end date = 3 start 1
4-6 quarter end date = 6 start 4
6-9 quarter end date = 9 start 7
10-12 quarter end date = 12 start 10 |
|
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
RIGHT is the correct function, i.e.:
QTRENDDT = CURRYYYY || RIGHT(CURRMM,2,'0') |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
and here is the algorithimic solution ...
Code: |
do i = 1 to 12
say right(i,2,"0") "qstart = " right(((i-1)%3)*3+1,2,"0") "qend = " right(((i-1)%3)*3+3,2,"0")
end
|
|
|
Back to top |
|
|
cvasu03
New User
Joined: 23 Mar 2007 Posts: 9 Location: USA
|
|
|
|
Thank you
I have coded the right statement in the following way.
CURRMM = RIGHT(CURRMM,2,'0'). I believe this statement was not liking.
I changed it to QTRENDDT = CURRYYYY || RIGHT(CURRMM,2,'0') as per superk. and it is working fine.
Code:
1-3 quarter end date = 12 start 1
4-6 quarter end date = 3 start 4
6-9 quarter end date = 6 start 7
10-12 quarter end date = 9 start 10
Thanks to all for your quick reply. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
1-3 quarter end date = 12 start 1
4-6 quarter end date = 3 start 4
6-9 quarter end date = 6 start 7
10-12 quarter end date = 9 start 10
|
still illogic/very peculiar , but if You like it that way
if You want people to understand what You mean it would be wiser to use a different terminology or a better description...
quarter start and quarter end are pretty standard terms and You are using them in an odd way |
|
Back to top |
|
|
|