5 Replies Latest reply: Dec 4, 2013 10:55 AM by MVM RSS


    Moazam Shareef

      I have two date column date-1 and date2 on a tubular block which trigger i have to use to insert date-1 data into date2 column with below format?






        • 1. Re: Trigger

          If both items are defined as dates then you do not need to use the TO_DATE function.  Also, don't use "-1" since that means subtract 1.  Use an underscore instead.  With that said your logic would look something like this:


          :BLK.DATE2 := :BLK.DATE_1;

          • 2. Re: Trigger



            Both date fields DATE_1 and DATE2 should have datatype as DATE and apply the format mask in property palette as 'DD-MON-YYYY' / 'DD-MON-RRRR'.


            Now if you are entering date in DATE_1 field and want to have same in DATE2, you can do the assignment

            :BLK.DATE2 := :BLK.DATE_1;

            on when-validate-item trigger of BLK.DATE_1.

            This is better if you are showing both date fields on screen.


            If DATE2 is hidden, you can have the assignment on PRE-INSERT trigger of BLK datablock.


            This will ensure that you are inserting same value in date fields.


            Another method is use synchronize with item property for DATE2.


            Hope this helps.

            • 3. Re: Trigger
              Moazam Shareef

              Thanks MVM.

              I import data from excel to forms i took date data as char into date1 which import sucessfully i want to convert those import date data into another item which is date datatype i tried the below codes on PRE-INSERT block level trigger but fail to achieve.


              :BLK.DATE:=TO_DATE('BLK.DATE1', 'DD/MON/YYY');


              how can i achive the task.

              • 4. Re: Trigger


                • 5. Re: Trigger



                  When importing date data as char - import it into a new item BLK.DATE1_CHAR, ensure that BLK.DATE1_CHAR is CHAR item and Non-database item.


                  The item BLK.DATE1 is DATE item and Database item and having format mask 'DD/MON/YYY'

                  And BLK.DATE is ofcourse DATE item and Database item and having format mask 'DD/MON/YYY'


                  Now on PRE-INSERT of BLK block, do the following:


                  :BLK.DATE1:=TO_DATE('BLK.DATE1_CHAR', 'DD/MON/YYY'); -- CHAR data to DATE and assign to DATE

                  :BLK.DATE:=:BLK.DATE1;-- copy DATE to another DATE;


                  This will ensure that you are inserting DATE in date fields (Note: DATE1 and DATE are columns in table with DATE datatype)


                  I dont understand the purpose of your last SELECT statement. Please explain.