View previous topic :: View next topic
|
Author |
Message |
jackzhang75
Active User
Joined: 09 Jun 2014 Posts: 125 Location: US
|
|
|
|
Hi experts,
I want to get only 2015.317 from following variable like
Code: |
"A=DATASET-OWNER-----(NULL) CREATION--------2015.317" |
How to use
to get right word you want like in this case
2015.317 ? Thanks |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Code: |
a = "DATASET-OWNER-----(NULL) CREATION--------2015.317"
parse var a with . "CREATION--------" crdate .
say crdate |
|
|
Back to top |
|
|
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
You can also know this if you know the starting position of date:
Code: |
A = "DATASET-OWNER-----(NULL) CREATION--------2015.317"
PARSE VAR A 46 CRDATE
SAY CRDATE |
|
|
Back to top |
|
|
jackzhang75
Active User
Joined: 09 Jun 2014 Posts: 125 Location: US
|
|
|
|
Thank you expters , thats work perfect |
|
Back to top |
|
|
jackzhang75
Active User
Joined: 09 Jun 2014 Posts: 125 Location: US
|
|
|
|
Another question , how to split 2015.317 into two varible ? one for 2015 as YEAR one for 317 as Date ? |
|
Back to top |
|
|
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
If you understand the above 2 methods then it should be really simple. What method are you using ? |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
As that line is fixed format you could have used SUBSTR.
Read the manual about PARSE. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
There are many ways:
Code: |
CreationDate = Right(Strip(A),8) |
|
|
Back to top |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 712 Location: Denmark
|
|
|
|
you could also do
dv=word(translate(var,' ','-'),5)
yes I know you asked for PARSE |
|
Back to top |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 712 Location: Denmark
|
|
|
|
or with parse, as there is only one dot in the string:
parse var v . '.' -4 dv +8 . |
|
Back to top |
|
|
|