oracle - comparing date with a predefined format pl sql -


i have function should accept date in format dd-mon-yy , should display in format dd-mm-yyyy. function have created :

create or replace function print_it(abc date) return date   v_date date; begin   if regexp_like(abc,'^[0-9]{2}-[a-z]{3}-[0-9]{2}$')       v_date := to_date(abc,'dd-mm-yyyy');   else     dbms_output.put_line('wrong format');   end if;   dbms_output.put_line('the date ');   return v_date; end print_it; 

but value returned wrong date format!!

no, it's not. date being output in format specified nls_date_format. want display if differently change parameter session:

alter session set nls_date_format = 'dd-mm-yyyy' 

note word display. that's does. that's should consider doing. way date displayed in no way effects way stored.

more might use to_char() appropriate format model display date, i.e. to_char(my_date, 'dd-mm-yyyy'). no longer date character.

it doesn't want display date you've said. you're returning value function, in case stick have. need transform date appropriate format display when taking out of database, store date in database. in turn means doesn't matter looks when stored in database, merely date.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -