Wednesday, October 20, 2010

Oracle Help get date from system in required format and its utility functions

the most often problem face by oracle+java programmer is when he code for getting the records on date variable and date format is different from the sql required format . It was the most irritating problem face by programmer i am giving solution for that u can check the below query on oracle .  

select to_date ('12-1-10','DD/MM/YYYY') from dual;


you will get the
TO_DATE('
---------
12-JAN-10

as output Nice !!
Some times it 's require that u have to minus the days e.g. 4 days from your date variable then u can do directly without coding it in java,

select to_date ('12-1-10','DD/MM/YYYY')-4 from dual;

the output will be,
TO_DATE('
---------
08-JAN-10

No comments:

Post a Comment