7 Replies Latest reply: Nov 8, 2009 11:22 PM by Zeeshan BaiG RSS

    Validating Date Format

    731133
      Hi,

      I am using DD-MON-YY format as date format in Oracle Forms. I have a field named "trans_date", I set it using current system's date and time. It dispalys date in DD-MON-YY format, that fine. But since date field is mouse manipulable it can be changed and after changing it does not allow save changes.

      Is there any way that I could check date format and perform validation.

      Thanks in advance
        • 1. Re: Validating Date Format
          Sarah
          hi
          But since date field is mouse manipulable it can be changed and after changing it does not allow save changes

          i did not get u very well what do u mean by Mouse Manipulable?
          SELECT TO_CHAR(SYSDATE, 'DD/MM/YY HH12:MI:SS') FROM dual; 
          Sarah

          Edited by: S@R@h on Nov 7, 2009 9:33 PM
          • 2. Re: Validating Date Format
            The Explorer
            Hi,

            Ensure that the "update allowed" property of trans_date field is set to TRUE. And include DD-MON-YY in the format mask property of that field.

            Hope it helps.

            Regards,
            O M E R.
            • 3. Re: Validating Date Format
              433935
              Hi

              You can use this to see the date format

              select sysdate from dual;

              you can set the date format in sql prompt

              setenv NLS_DATE_FORMAT "dd-mon-yyyy hh24:mi:ss"

              select sysdate from dual;



              Jamil
              • 4. Re: Validating Date Format
                Sarah
                hi

                I am using DD-MON-YY format as date format in Oracle Forms

                try to use date format something like this.
                dd/mm/yyyy
                or
                DD-MON-YYYY HH24:MI:SS
                Or if u wanna check u r date format then u may try something like this.
                set initial value to.
                $$DBdatetime$$
                • 5. Re: Validating Date Format
                  Sarah
                  This article assumes that the displayed date item has the format mask "DD Mon YYYY"
                  and corrects "MMDDRRRR" or "MM/DD/RRRR" when American language settings are used.
                  When other language settings are used, such as United Kingdom, then "DDMMRRRR" or "DD/MM/RRRR" will be corrected.
                  create a function something like this.
                  FUNCTION lfn_dateFormatCorrection RETURN BOOLEAN IS
                  
                    v_charDate   VARCHAR2(30) := NAME_IN('SYSTEM.CURSOR_VALUE');
                    v_dateDate   DATE;
                    v_return     BOOLEAN := FALSE;
                    FUNCTION convertDate(p_mask IN VARCHAR2) RETURN BOOLEAN IS
                    BEGIN
                      v_dateDate := TO_DATE(v_charDate,p_mask);
                      COPY(TO_CHAR(v_dateDate,'DD Mon YYYY'),NAME_IN('SYSTEM.CURSOR_ITEM'));
                      RETURN(TRUE);
                    EXCEPTION
                    WHEN OTHERS THEN
                      RETURN(FALSE);
                    END convertDate;
                  
                  BEGIN
                  
                    IF INSTR(GET_APPLICATION_PROPERTY(USER_NLS_LANG),'AMERICAN') != 0 THEN
                      IF convertDate('MMDDRRRR') THEN
                        v_return := TRUE;
                      ELSIF convertDate('MM/DD/RRRR') THEN
                        v_return := TRUE;
                      END IF;
                    ELSE
                      IF convertDate('DDMMRRRR') THEN
                        v_return := TRUE;
                      ELSIF convertDate('DD/MM/RRRR') THEN
                        v_return := TRUE;
                      END IF;
                    END IF;
                    
                    RETURN(v_return);
                  
                  END;
                  Sarah
                  • 6. Re: Validating Date Format
                    Andreas Weiden
                    it does not allow save changes.
                    what does that mean? do you get any error?
                    • 7. Re: Validating Date Format
                      Zeeshan BaiG
                      You can check the Format mask of an item at any place with
                        get_item_property(itemname,format_mask);
                      if you want to set explicitly then use
                        set_item_property(itemname,format_mask,'DD.MM.RRRR');
                      etc etc.

                      Plz mark it helpful if it is :)

                      Regards,
                      Baig