Data format [message #82712] |
Thu, 26 June 2003 01:19 |
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 #82716 is a reply to message #82712] |
Thu, 26 June 2003 06:57 |
|
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
|
|
|