dbranch Posted April 14, 2010 Share Posted April 14, 2010 I have set my SQL statement to group invoices by month by using the month function, i.e month(Date). This works fine and returns the month as an integer whenused as a field. I was wondering if anyone has written an expression to convert this integer into a month label, either as the month name or the three letter abreviation? Thanks. Link to comment Share on other sites More sharing options...
slow Posted April 15, 2010 Share Posted April 15, 2010 try to use this in your textfield (class type String) expression:$F{MONTH}.intValue()==1?"JAN": $F{MONTH}.intValue()==2?"FEB": $F{MONTH}.intValue()==3?"MAR": $F{MONTH}.intValue()==4?"APR": $F{MONTH}.intValue()==5?"MAY": $F{MONTH}.intValue()==6?"JUN": $F{MONTH}.intValue()==7?"JUL": $F{MONTH}.intValue()==8?"AUG": $F{MONTH}.intValue()==9?"SEP": $F{MONTH}.intValue()==10?"OCT": $F{MONTH}.intValue()==11?"NOV":"DEC"; ______________________________if it works... KARMA point please! : ) Link to comment Share on other sites More sharing options...
dbranch Posted April 17, 2010 Author Share Posted April 17, 2010 Thanks..It worked like a charm Link to comment Share on other sites More sharing options...
pacoomu Posted April 23, 2010 Share Posted April 23, 2010 Hello, I think the best way to resolve this problem is to create a table with month names and numbers, and join it. Something like this: SELECT table1.field1, table1.field2, months.name FROM table1 LEFT JOIN months on months.id=month(date) Link to comment Share on other sites More sharing options...
thangalin Posted May 13, 2010 Share Posted May 13, 2010 (new java.text.DateFormatSymbols().getShortMonths()[$F{MONTH} - 1]).toUpperCase() Post Edited by thangalin at 05/13/2010 05:21 Link to comment Share on other sites More sharing options...
thangalin Posted May 13, 2010 Share Posted May 13, 2010 Helps with I18N, if that's an issue ... Post Edited by thangalin at 05/13/2010 05:06 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