Converting dates in Natural under unix

Hi all,
I would like to know if there is a way to convert a date in format DD/MM/YY to YYYYMMDD.
I think it can be done using *DATE or a similar variable, but in this environment I have no help and I really can´t remember how to do it.

Thanks everyone,
Gabriel.

Gabriel
Here is a small sample. Testet on Natural 414 under Com-Plete. But should work the same way under Natural 6.11 Unix:

DEFINE DATA LOCAL
1 D1(A8) INIT <‘22/11/05’>
1 D(D)
1 D2(A8)
END-DEFINE
MOVE EDITED D1 TO D(EM=DD/MM/YY)
MOVE EDITED D(EM=YYYYMMDD) TO D2
WRITE D1 / D / D2
END

Ups… The type definitions have been converted into smilies (due to cut 'n paste ?!).
D1 and D2 are both A8.

Great Klaus!!!

Thank you for your quick and exact response!

Gabriel.

Hint:
you have to make your natural coding within a code section:
[ code ] … [/ code ] … without blanks before and after ] [


DEFINE DATA LOCAL 
1 D1(A8) INIT <'22/11/05'> 
1 D(D) 
1 D2(A8) 
END-DEFINE 
MOVE EDITED D1 TO D(EM=DD/MM/YY) 
MOVE EDITED D(EM=YYYYMMDD) TO D2 
WRITE D1 / D / D2 
END 

or you write
1 D2 ( A8 )

because 8 ) … without space inbetween … are converted into smilies wearing sunglases 8)

Ahh… I see. And a

:D

is converted to :smiley: and a

:) 

into :slight_smile:

Alternatively I can also activate the "Disable Smilies’ checkbox to disable this “Character to Emoticons conversion”.

Thanks for that hint.

Be careful when converting dates. If your xx/xx/xx is not a valid mm/dd/yy you will get a runtime error. On MVS you can check for a valid date format using


IF #DATE-MDY = MASK (MM/DD/YY)
   MOVE EDITED #DATE-MDY (EM=MM/DD/YY) TO #DATE-D
   MOVE EDITED #D  TO #DATE-CYMD (EM=YYYYMMDD)
ELSE
   WRITE #DATE-MDY 'is not valid date in mm/dd/yy format.'
END-IF