Home » Developer & Programmer » Forms » Data format
Data format [message #82712] Thu, 26 June 2003 01:19 Go to next message
Jeslie
Messages: 26
Registered: April 2003
Junior Member
Hi All

I have a Text Box to enter the Date.

User can enter the date in any format(01.01.03 , 01/01/03 etc)

I need to format the date to dd-mon-yyyy.(01-JAN-2003)

My Problem is if I set the Format Mask property as DD-MON-YYYY forms doesnot allow the user to enter date in other formats. I think the problem is because of the default date format.

Can U help me to sort this Problem

Thanks
Re: Data format [message #82713 is a reply to message #82712] Thu, 26 June 2003 06:37 Go to previous messageGo to next message
magnetic
Messages: 324
Registered: January 2003
Senior Member
put a when-validate-item on that item with code
:field :=to_date(to_char(:field,DD-MON-YYYY'));
Re: Data format [message #82716 is a reply to message #82712] Thu, 26 June 2003 06:57 Go to previous message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
DD/MM/RRRR is already a little more flexible, but you can create your own date validation:
1. create a non database field as 'CHAR' instead of date. Maximum size = 10 (DD/MM/YYYY).

You create a when-validate-item trigger on the item:
Declare
	Date_Exception Exception ;
Begin
	If length(:dual.test_date) = 6 then
		:dual.test_date := to_char(to_date(:dual.test_date,'ddmmrr'),'dd/mm/yyyy');
	Elsif length(:dual.test_date) = 8 then
		:dual.test_date := to_char(to_date(:dual.test_date,'ddmmyyyy'),'dd/mm/yyyy');
	Elsif length(:dual.test_date) = 10 then
		:dual.test_date := to_char(to_date(:dual.test_date,'DD-MM-YYYY'),'dd/mm/yyyy');	  	
	Else
	  RAISE date_exception;
	End If;
Exception
  When date_exception Then
  	Message('acceptible date formats are: ddmmyy(yy), dd/mm/yyyy, dd-mm-yyyy');pause;	
    RAISE FORM_TRIGGER_FAILURE;  	
  When Others Then		
    Message(sqlerrm);pause;
    Raise form_trigger_failure;
End;
and as a final step, you copy the value of this non-database item to a date database item. Modify as you like...

Perhaps it is possible to find a better way, but this is what I would do (at first glance). Beware, it isn't tested and it is written on the fly...

Good luck,
MHE
Previous Topic: Oracle Forms 6: missing indentifier error
Next Topic: Date field Entry/Convertion in forms
Goto Forum:
  


Current Time: Sat Apr 20 04:43:50 CDT 2024