Re: format mask for date item.

From: <cfischer_at_my-deja.com>
Date: Mon, 21 Jun 1999 18:27:07 GMT
Message-ID: <7km05b$hl4$1_at_nnrp1.deja.com>


In article <376a679a.0_at_news.cadvision.com>,   "Sheldon Wang" <swang_at_online-can.com> wrote:
> Hi, there,
>
> I was wondering if I can use two format masks to a date item on Forms4.5. I
> would like the user to enter either in format 'DDMMYYYY' or 'DD/MM/YYYY'.
> So I would like both of these formats to be working at runtime.
>
> Any help will be greatly appreciated.
>

Unfortunately you can only specify one format mask on any field type. The way I've gotten around this is to create a "shadow" text item with a datatype of character with length long enough to hold the various date-types I want to support.

Then in a post-text-item trigger on that item, test to ensure that it's got a valid date in it by doing:

DECLARE
  v_date DATE;
  v_is_valid BOOLEAN := FALSE;
BEGIN
  IF NOT v_is_valid THEN
    BEGIN
-- first allowed date format

      v_date := TO_DATE(:system.trigger_item
                        ,'DD-MON-YYYY')
      v_is_valid := TRUE;
    EXCEPTION
      WHEN VALUE_ERROR THEN
        v_is_valid := FALSE;
      WHEN OTHERS THEN
        RAISE;

    END;
  END IF;   IF NOT v_is_valid THEN
    BEGIN
-- second allowed date format
      v_date := TO_DATE(:system.trigger_item
                        ,'dd/mm/yyyy')
      v_is_valid := TRUE;
    EXCEPTION
      WHEN VALUE_ERROR THEN
        v_is_valid := FALSE;
      WHEN OTHERS THEN
        RAISE;

    END;
  END IF;
-- etc for other formats

  IF v_is_valid THEN
    :block.real_date_item := v_date;
  END IF;
END; Hope this helps.

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't. Received on Mon Jun 21 1999 - 20:27:07 CEST

Original text of this message