Wednesday, October 15, 2008

To_date in oracle

Applications which are build with .Net or Java and oracle as back end usually face problems while assigning values to the date parameters sent thtough oracle procedure.

To_Date() oralce function converts from string type to date (oracle) type using format string.
Syntax:-

To_date(date(string),format(string))
simillarly
To_char() oracle function converts from a type (date,float, etc...) to a char type.

when date parameter value is sent to procedure from .Net or oracle, either it can be declared as date or varchar with specific format hard coded.

Ex:-


Select to_date('14/05/2008','dd/MM/yyyy') from dual;
displays the date but from the date object that is created in the above query.

Slect to_char(sysdate,'dd/MM/yyyy') from dual;
converts current (system date) to string using dd/MM/yyyy format and displays the formated date.

No comments: