Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What would be the easiest way to replace chars. in a str
Message
 
To
06/02/2000 11:13:13
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00327059
Message ID:
00328635
Views:
28
*Try this for variable structure
DS="AADSE 1999/11/28 ASDF 1999/10/29"
leftseg=alltrim(left(DS,at("ASDF",DS)-1))
rightseg=trim(substr(DS,at("ASDF",DS),100))
leftdate=alltrim(substr(leftseg,at("AADSE",leftseg)+6,100))
rightdate=alltrim(substr(rightseg,at("ASDF",rightseg)+5,100))
leftdate="AADSE {^"+strtran(leftdate,"/","-")+"}"
rightdate="ASDF {^"+strtran(rightdate,"/","-")+"}"
converteddate=leftdate+" "+rightdate
? converteddate


>>>I have a string that could contain one or more dates. The thing is that those date are of type character.
>>>
>>>How could I replace those dates in this string by their equivalent representation in date format
>>>
>>>Exemple:
>>>
>>>"AADSE 1999/11/28 ASDF 1999/10/29
>>>
>>>becomes
>>>
>>>"AADSE {^1999-11-28} ASDF {^1999-10-29}"
>>>
>>>
>>>Is there a VFP function that would make it possible to do this?
>>>If not what would be the easiest way?
>>
>>If the format is constant, the following might help
>>*procedure DateStringConvert (sDS)
>>parameter sDS
>>* If the format always the same
>>* 0 1 2 3
>>* 12345678901234567890123456789012
>>sDS=alltrim("AADSE 1999/11/28 ASDF 1999/10/29")
>>* Needs to be
>>* "AADSE {^1999-11-28} ASDF {^1999-10-29}"
>>sCDS=[AADSE {^]+substr(sDS,7,10)+[}]+[ ASDF ]+[{^]+substr(sDS,23,10)+[}]
>>do while at([/],sCDS)>0
>>sCDS=stuff(sCDS,at([/],sCDS),1,[-])
>>enddo
>>? sCDS
>>cancel
>
>The format is not constant but thanks for your help. Maybe I will use part of that code.
>
>
>Thanks Terry.
Imagination is more important than knowledge
Previous
Reply
Map
View

Click here to load this message in the networking platform