Question

I am trying to find a way to flip a date around in the natural programming language.

What I have is a #DOB which is equal to 19700830 yyyymmdd and I need it to be mmddyyyy. Is there an easy way to do this in Natural?

Question: How can I flip the date around to my specific format the easiest and most efficient way in Natural?

Code:

    RESET #NAME(A21/25) 
          #ROLE(A7/25) 
          #DOB(A10) 
          #I(P3)    
          #ADC(A1/25) 
          #SSN(A9)                   

I have tried using the FOR loop to get my results, but it is bulky and won't compile as of yet.. It is bulky at best.

    FOR INDEX(P3) FROM 1 TO 8
       IF INDEX >= 1 AND INDEX <= 4
          #YYYY = #DOB(INDEX) 

       IF INDEX >= 5 AND INDEX <= 6
          #MM = #DOB(INDEX) 

       IF INDEX >= 7 AND INDEX <= 7
          #DD = #DOB(INDEX) 
    LOOP

This is what I would like to do but I am not completely certain that it will work. I think there is a better way but I do not have any real great books on the language and it is something that I do not do all that often. Once or twice a year so it is new to me.

Was it helpful?

Solution

The easiest way to do this is two redefine your variable and them just move and use the pieces of the redefine.

    DEFINE   #DOB(A10) 
    REDEFINE #DOB(#Y(A4) #M(A2) #D(A2)) 

Then you can just use the piece and move them around the way that you want.

    WRITE WORK FILE 2 #M ',' #D ',' #Y
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top