# How to prevent NAT1137

**URL:** <https://techcommunity.softwareag.com/t/how-to-prevent-nat1137/79978>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [January 20, 2009, 5:51pm UTC](https://techcommunity.softwareag.com/t/how-to-prevent-nat1137/79978 "2009-01-20T17:51:56Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mun1ek\_2](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mun1ek\_2](https://techcommunity.softwareag.com/u/mun1ek_2)\
**Post date:** [January 20, 2009, 5:51pm UTC](https://techcommunity.softwareag.com/t/how-to-prevent-nat1137/79978/1 "2009-01-20T17:51:56Z")

</div>

How to check date field before MOVE EDITED in something like that:

IF #DATE NE 0  
MOVE EDITED #DATE (EM=YYYY-MM-DD) TO #A10  
END-IF

I get NAT1137 (Date is outside valid range. ) in line with MOVE EDITED.

---

<div class="post-metadata">

**Author:** ![Finn\_the\_Dane1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/finn_the_dane1/32/132_2.png) [@Finn\_the\_Dane1](https://techcommunity.softwareag.com/u/Finn_the_Dane1)\
**Post date:** [January 20, 2009, 6:04pm UTC](https://techcommunity.softwareag.com/t/how-to-prevent-nat1137/79978/2 "2009-01-20T18:04:29Z")

</div>

I can recommend using the MASK option  
See “MASK option” and “Checking dates” in the documentation under  
“logical condition criteria”.  
Finn

---

<div class="post-metadata">

**Author:** ![mun1ek\_2](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mun1ek\_2](https://techcommunity.softwareag.com/u/mun1ek_2)\
**Post date:** [January 20, 2009, 6:51pm UTC](https://techcommunity.softwareag.com/t/how-to-prevent-nat1137/79978/3 "2009-01-20T18:51:31Z")

</div>

thanks very much 🙂

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [January 20, 2009, 9:14pm UTC](https://techcommunity.softwareag.com/t/how-to-prevent-nat1137/79978/4 "2009-01-20T21:14:59Z")

</div>

There is also a compiler option (MASKCME) that you might want to look at. It makes the MASK test compatible with the MOVE EDITED statement.

Enter COMPOPT at a prompt to see the compiler options.

steve

---

<div class="post-metadata">

**Author:** ![Jose\_Luis\_Robles](https://avatars.discourse-cdn.com/v4/letter/j/7993a0/32.png) [@Jose\_Luis\_Robles](https://techcommunity.softwareag.com/u/Jose_Luis_Robles)\
**Post date:** [July 30, 2009, 2:16pm UTC](https://techcommunity.softwareag.com/t/how-to-prevent-nat1137/79978/5 "2009-07-30T14:16:02Z")

</div>

Hi, I´m a new member. Excuse me for my bad English.

I can recomended using the MASK option with follow example:

IF #DATE EQ MASK (19-20YYMMDD)  
MOVE EDITED #DATE TO #A10  
END-IF

The MOVE EDITED statement is not avaliable with date less than 1900

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [July 30, 2009, 3:58pm UTC](https://techcommunity.softwareag.com/t/how-to-prevent-nat1137/79978/6 "2009-07-30T15:58:12Z")

</div>

This is incorrect. MOVE EDITED works for dates in the year range 1571-2699. (or is it 1572? I never remember).

See following program and output

define data local  
1 #date (d)  
1 #a (a10)  
end-define  
\*  
move edited ‘17000214’ to #date (em=yyyymmdd)  
\*  
move edited #date (em=yyyy-mm-dd) to #a  
write 5T ‘=’ #a  
end  
PAGE # 1 DATE: 09-07-30  
PROGRAM: DATETEMP LIBRARY: CALENDAR

```
#A: 1700-02-14

```

---

<div class="post-metadata">

**Author:** ![Jose\_Luis\_Robles](https://avatars.discourse-cdn.com/v4/letter/j/7993a0/32.png) [@Jose\_Luis\_Robles](https://techcommunity.softwareag.com/u/Jose_Luis_Robles)\
**Post date:** [July 30, 2009, 5:38pm UTC](https://techcommunity.softwareag.com/t/how-to-prevent-nat1137/79978/7 "2009-07-30T17:38:02Z")

</div>

Sorry, That’s ok. The MOVE EDITED statement is not avaliable with date less than 1582. I think that a good date check could be:

IF #DATE EQ MASK (16-20YYMMDD)  
MOVE EDITED #DATE (EM=YYYY/MM/DD) TO #A10  
END-IF

However, I always use the check following because I don´t think that a date less than 1900 is all correct.

IF #DATE EQ MASK (19-20YYMMDD)  
MOVE EDITED #DATE (EM=YYYY/MM/DD) TO #A10  
END-IF

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [July 30, 2009, 7:25pm UTC](https://techcommunity.softwareag.com/t/how-to-prevent-nat1137/79978/8 "2009-07-30T19:25:09Z")

</div>

> [@Jose Luis Robles](#):
>
> IF #DATE EQ MASK (19-20YYMMDD)  
> MOVE EDITED #DATE (EM=YYYY/MM/DD) TO #A10  
> END-IF

I wouldn’t use such a “combined” edit mask (with numbers and letters). There are problems with some leap years.  
Example:

```auto
define data local
01 #date (a8 )
01 #a10 (A10)
end-define
#date := "19000229" /* 1900 was not a leap year!
IF #DATE EQ MASK (19-20YYMMDD)
  write 'mask 19-20YYMMDD says: valid'
else
  write 'mask 19-20YYMMDD says: invalid'
END-IF
IF #DATE EQ MASK (YYYYMMDD)
  write 'mask YYYYMMDD says: valid'
else
  write 'mask YYYYMMDD says: invalid'
END-IF
end
```

---

<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:** [July 30, 2009, 8:35pm UTC](https://techcommunity.softwareag.com/t/how-to-prevent-nat1137/79978/9 "2009-07-30T20:35:44Z")

</div>

To clarify what Matthias is talking about, if you don’t specify the year in an edit mask check, Natural will use the current year for the check. If you only specify YY in the edit mask, Natural will use a century of its choosing (which century will depend on a session parameter). So, it is not a good idea to use combined masks. Instead, do two separate checks:

```auto

IF #DATE-CYMD NE MASK (YYYYMMDD)
  WRITE 'INVALID DATE'
END-IF
IF #DATE-CYMD NE MASK (19-20......)
  WRITE 'DATE IS NOT BETWEEN 1900 AND 2099'
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:51pm UTC](https://techcommunity.softwareag.com/t/how-to-prevent-nat1137/79978/10 "2021-04-02T14:51:23Z")

</div>


