Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MON-YY - date format... is this possible

Status
Not open for further replies.

jhoann

Programmer
Apr 18, 2002
81
0
0
PH
hi ...
i need a date format like this 'MON-YY' my code is like this :
------------
date1 := to_date(date2,'MON-YY');
------------
i put it in when validate item trigger.. and when i press it, there's an error ...

can you help me , how to format my date like 'MON-YY'
in my textbox i type like this : 'May 1999' then it should be 'MAY-99'... how to do this...???

thanks a lot

JHoann
 
The TO_DATE function converts a value to a date FROM a specific format mask. in your example date2 should be a char datatype not a date. You need the TO_CHAR call to convert a value that is already a date TO a specific format. In this case date2 is a date datatype.

date1 := To_Char(date2,'MON-YY');

If you are using forms to validate the format you can enter your format into the Format Mask property of the date datatype item.
 
thanks lewisp :

date1 is a date datatype
date2 is a char datatype

my code is like this :

date1 := to_date(date2,'MON-YY');

but it didn't work ... how to convert my date to 'MON-YY' format... when i tried 'DD-MON-YY' it works...but 'MON-YY' didn't work :c

pls help me

thanks again

jhoann
 
'DD-MON-YY' is probably your default SESSION NLS_DATE_FORMAT. Expression date1 := to_date(date2,'DD-MON-YY') converts date2 using default format mask to character (as the first parameter of to_date is VARCHAR2), then converts this string to date, using 'DD-MON-YY' mask. As you may see it in fact does NOTHING: the same as date1 := date2.
Dates are stored in some internal format NOT HOLDING any specific FORMAT attribute, so may be converted to string using arbitrary format mask . If both date1 and date2 are dates, you do not need any conversion. Though if you need to DISPLAY a date using some format mask, you should convert it to_char.

Regards, Dima
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top