aluferrari Posted August 21, 2013 Share Posted August 21, 2013 Hi,We are looking to create a new calculated field by extracting Month and Year (in 2 separate fields) from a column containing Date values. We have tried many things but nothing seems to be working.We are on Oracle database and we have tried all TO_DATE functions and TO_CHAR functions but in vain. Please help us with correct syntax of DoMEL to achieve what we want.Thanks in advance. Link to comment Share on other sites More sharing options...
ajinkya_c Posted August 22, 2013 Share Posted August 22, 2013 Hi,Here is sample queryselectTo_char(Sysdate, 'MONTH') as Month,To_char(Sysdate, 'MM') as MM,To_char(Sysdate, 'YYYY') as Year,To_char(Sysdate, 'YY') as YY,To_char(Sysdate, 'Month YYYY') as mmyyfrom dualhope this helps.ThanksAjinkya Link to comment Share on other sites More sharing options...
aluferrari Posted August 22, 2013 Author Share Posted August 22, 2013 Thanks for the answer. We are aware of these functions in Oracle, but how do we add them in Jasper? Here is some background: Our Employee table has hiredate column. We want to create a cross tab report that would show month-wise & year-wise employees hired. Thanks again. Link to comment Share on other sites More sharing options...
ajinkya_c Posted August 23, 2013 Share Posted August 23, 2013 Hi,Your query may be:selectTo_char( hiredate, 'MONTH') as Month,To_char( hiredate, 'YYYY') as Year,To_char hiredate, 'Month YYYY') as YearMonth from EmployeeThis may be your query, used month, year or YearMonth in crosstab whichever suits your reporting requirement.ThanksAjinkya Link to comment Share on other sites More sharing options...
aluferrari Posted August 23, 2013 Author Share Posted August 23, 2013 We dropped the idea of creating calculated field. Instead we created a derived table:SELECT emp.*, TO_CHAR(HIREDATE,'MM') HIREMONTH, TO_CHAR(HIREDATE,'YY') HIREYEAR FROM EMPLOYEE emp;Thank you Ajinkya. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now