Showing posts with label Date. Show all posts
Showing posts with label Date. Show all posts

03 May, 2013

Compare JBO Date Programatically

To compare two jbo date programatically, l convert jbo date to sql date and then compare sql dates

oracle.jbo.domain.Date jboDate1 = new oracle.jbo.domain.Date();
oracle.jbo.domain.Date jboDate2 = new oracle.jbo.domain.Date();

java.sql.Date sqlDate1 =jboDate1.dateValue();
java.sql.Date sqlDate2 =jboDate2.dateValue(); 

//Compare sql Date
if (sqlDate1.before(sqlDate2 )) {     
  //Write Your Code
}

Thanks

13 November, 2012

Generate list of dates and times


I want to create query returns list of dates and time for example
1-Jan-2012
1-Jan-2012 12:30:00 AM
1-Jan-2012 13:00:00 AM
1-Jan-2012 13:30:00 AM
1-Jan-2012 14:00:00 AM
.................
.................
1-Jan-2012 11:00:00 PM
1-Jan-2012 11:30:00 PM

To execute the previous requirement I can use the below query
   SELECT TO_DATE ('1-1-2012', 'DD-MM-RRRR') + (LEVEL - 1) / 48 DATE_TIME  
    FROM DUAL  
 CONNECT BY LEVEL <= 48;  

04 August, 2011

Average on Dates Columns

SA,
As we know that is is impossible to calculate average on non numeric column.

SQL> select avg(hire_date) from scott.emp;

It will raise error
ORA-00932: inconsistent datatypes: expected NUMBER got DATE 

There is workaround to calculate avg on date columns.
Workaround is to convert date to julian date and then calculate average.


So the following is solution to make average on date column
SELECT TO_DATE(TRUNC(AVG( TO_CHAR(hire_date,'J'))),'J') FROM EMP;

Thanks

ADF : Scope Variables

Oracle ADF uses many variables and each variable has a scope. There are five scopes in ADF (Application, Request, Session, View and PageFl...