3 Replies Latest reply on May 23, 2011 8:13 AM by LaRetta_1

    4 Digit Year ONLY

    Mitch

      Title

      4 Digit Year ONLY

      Post

      Hi,

      I have a database with three separate fields, one for DAY, MONTH and YEAR.

      Is there any way to restrict a each field to only accept 4 digit YEAR (1987 or 2011), 2 digit DAYS (01 - 31) and 2 digit MONTHS (01 - 12).

      Mitch

        • 1. Re: 4 Digit Year ONLY
          ninja

          Since they are separate fields, it would be possible to handle them as numbers rather than dates.

          As a number field, you can then set a validation on the field that the number be between X and Y.

          If you know that all reasonable dates to be used are rather current, set the limits between 1960 and 2100 or as appropriate.

          If you are doing past work (Archaeological - 100BC type stuff) this approach wouldn't work so well.

          You can also force formatting at the layout level...check out the field formatting options in Inspector.

          • 2. Re: 4 Digit Year ONLY
            philmodjunk

            What problem are you solving by having three separate fields for day, month, year instead of using a single date field?

            • 3. Re: 4 Digit Year ONLY
              LaRetta_1

              Also keep in mind that, even if numbers, using the range  specification validation will not restrict text from being entered in  additional to a 'legal' number, i.e. 1z3 is within range for day.

              Depending  upon your purpose here, it could cause problems.  I might include an  auto-enter (replace) with GetAsNumber ( Self ) .  You could also use  script triggers but that is no guarantee (it can possibly break whereas  field-level validation would not).