# Global Date Restriction&MakeDateText in Codeunit 1

**URL:** <https://www.dynamicsuser.net/t/global-date-restriction-makedatetext-in-codeunit-1/10204>\
**Category:** Developers Forum\
**Created:** [August 25, 2005, 3:32pm UTC](https://www.dynamicsuser.net/t/global-date-restriction-makedatetext-in-codeunit-1/10204 "2005-08-25T15:32:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tarek\_Demiati](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@Tarek\_Demiati](https://www.dynamicsuser.net/u/Tarek_Demiati)\
**Post date:** [August 25, 2005, 3:32pm UTC](https://www.dynamicsuser.net/t/global-date-restriction-makedatetext-in-codeunit-1/10204/1 "2005-08-25T15:32:26Z")

</div>

I’m trying to apply a global date restriction in the entire application (I’m on a 3.60) Basically I want to block any users trying to enter a date which is smaller than the 01/01/1980 (1st Jan 1980) I started to look at the function **MakeDateText in CodeUnit 1** This function seems to be called each time a Date field is VALIDATED. So I thought that’s exactly what I needed since I do not want to waste my valuable time implementing a check on each date field of the entire database. Below is the Custom Code I’ve added Codeunit 1 MakeDateText(VAR DateText : Text[250]) : Integer GLSetup.CheckDate(DateText); // \>\> Tarek - 25th August 2005 Table 98 - GLSetup // \>\> Tarek - 25th August 2005 CheckDate(DateTextPAR : Text[250]) IF EVALUATE(DateLOC, FORMAT(DateTextPAR) ) THEN IF DateLOC \< 01011980D THEN ERROR(‘Date %1 is incorrect, the date should be greated than the 1st January 1980’, DateLOC); // \<\< Tarek - 25th August 2005 But it does not work really well : 1/ it does not block the user from entering a date below 1980 (even if the error message from the CheckDate function is displayed) 2/ the error message do not appears just after the first validate (it appears after the second validate and shows the previous value not the current one) Has someone got a solution to implement a Global Date Restriction ?

---

<div class="post-metadata">

**Author:** ![Marq](https://avatars.discourse-cdn.com/v4/letter/m/eb9ed0/32.png) [@Marq](https://www.dynamicsuser.net/u/Marq)\
**Post date:** [August 25, 2005, 9:01pm UTC](https://www.dynamicsuser.net/t/global-date-restriction-makedatetext-in-codeunit-1/10204/2 "2005-08-25T21:01:15Z")

</div>

I think, but I do not know fore sure, that this function is used to format a date into a readable textformat, So the date is stored directly in the database and this function is called to display the value Regards, Mark Brummel
