# Converting dates in Natural under unix

**URL:** <https://techcommunity.softwareag.com/t/converting-dates-in-natural-under-unix/60340>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [November 22, 2005, 3:25pm UTC](https://techcommunity.softwareag.com/t/converting-dates-in-natural-under-unix/60340 "2005-11-22T15:25:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabriel](https://avatars.discourse-cdn.com/v4/letter/g/9de0a6/32.png) [@Gabriel](https://techcommunity.softwareag.com/u/Gabriel)\
**Post date:** [November 22, 2005, 3:25pm UTC](https://techcommunity.softwareag.com/t/converting-dates-in-natural-under-unix/60340/1 "2005-11-22T15:25:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Klaus\_Sponagel](https://avatars.discourse-cdn.com/v4/letter/k/3bc359/32.png) [@Klaus\_Sponagel](https://techcommunity.softwareag.com/u/Klaus_Sponagel)\
**Post date:** [November 22, 2005, 3:52pm UTC](https://techcommunity.softwareag.com/t/converting-dates-in-natural-under-unix/60340/2 "2005-11-22T15:52:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Klaus\_Sponagel](https://avatars.discourse-cdn.com/v4/letter/k/3bc359/32.png) [@Klaus\_Sponagel](https://techcommunity.softwareag.com/u/Klaus_Sponagel)\
**Post date:** [November 22, 2005, 3:56pm UTC](https://techcommunity.softwareag.com/t/converting-dates-in-natural-under-unix/60340/3 "2005-11-22T15:56:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Gabriel](https://avatars.discourse-cdn.com/v4/letter/g/9de0a6/32.png) [@Gabriel](https://techcommunity.softwareag.com/u/Gabriel)\
**Post date:** [November 22, 2005, 4:16pm UTC](https://techcommunity.softwareag.com/t/converting-dates-in-natural-under-unix/60340/4 "2005-11-22T16:16:05Z")

</div>

Great Klaus!!!

Thank you for your quick and exact response!

Gabriel.

---

<div class="post-metadata">

**Author:** ![Weihnachtsbar](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/weihnachtsbar/32/146_2.png) [@Weihnachtsbar](https://techcommunity.softwareag.com/u/Weihnachtsbar)\
**Post date:** [November 22, 2005, 8:02pm UTC](https://techcommunity.softwareag.com/t/converting-dates-in-natural-under-unix/60340/5 "2005-11-22T20:02:24Z")

</div>

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

```auto

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)

---

<div class="post-metadata">

**Author:** ![Klaus\_Sponagel](https://avatars.discourse-cdn.com/v4/letter/k/3bc359/32.png) [@Klaus\_Sponagel](https://techcommunity.softwareag.com/u/Klaus_Sponagel)\
**Post date:** [November 22, 2005, 8:20pm UTC](https://techcommunity.softwareag.com/t/converting-dates-in-natural-under-unix/60340/6 "2005-11-22T20:20:27Z")

</div>

Ahh… I see. And a

```auto
:D
```

is converted to 😃 and a

```auto
:) 
```

into 🙂

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

Thanks for that hint.

---

<div class="post-metadata">

**Author:** ![Jerome\_LeBlanc](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/jerome_leblanc/32/111_2.png) [@Jerome\_LeBlanc](https://techcommunity.softwareag.com/u/Jerome_LeBlanc)\
**Post date:** [November 22, 2005, 8:36pm UTC](https://techcommunity.softwareag.com/t/converting-dates-in-natural-under-unix/60340/7 "2005-11-22T20:36:00Z")

</div>

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

```auto

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
```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 2:40pm UTC](https://techcommunity.softwareag.com/t/converting-dates-in-natural-under-unix/60340/8 "2021-04-02T14:40:21Z")

</div>


