2006 IR Open Dicussion Posted August 26, 2006 Share Posted August 26, 2006 By: Kuldip Shah - kuldipshah Displaying date from database in report 2006-02-22 07:22 I want to display date from database in different format. I am trying following but does not work. It's not displaying any date and no exception is raised. Please help. Data field is: <field name="gameday" class="java.util.Date"> </field> ... Variable is: <variable name="v_gameday_display" class="java.lang.String" resetType="Group" resetGroup="game_num"> <variableExpression><![CDATA[(new SimpleDateFormat("MMMMM dd, yyyy")).format($F{gameday})]]></variableExpression> </variable> ... textField is: <textFieldExpression class="java.lang.String"><![CDATA[$V{v_gameday_display}]]></textFieldExpression> </textField> I don't know what went wrong there... Thank you. By: macoute3 - macoute3 RE: Displaying date from database in report 2006-02-22 07:36 I've tried: <variable name="v_gameday_display" class="java.lang.String" resetType="Report" calculation="Nothing"> <variableExpression><![CDATA[(new SimpleDateFormat("MMMMM dd, yyyy")).format(new Date())]]></variableExpression> </variable> <textFieldExpression class="java.lang.String"><![CDATA[$V{v_gameday_display}]]></textFieldExpression> </textField> ant it works By: Kuldip Shah - kuldipshah RE: Displaying date from database in report 2006-02-22 07:42 I think you tried it with current system date. I want formatting date (for e.g. order purchase date) coming from database. Date is coming from db is in format "yyyy-MM-dd". By: Aegis Thorne - aegisthorne RE: Displaying date from database in report 2006-02-22 09:49 Is the data coming from the database as a String ? You should use SimpleDateFormat.parse(String) instead of SimpleDateFormat.format(Object); the second just accepts a Date or a Number. If that isn't it can you give the text of the exception ? By: Kuldip Shah - kuldipshah RE: Displaying date from database in report 2006-02-22 12:12 Guys, Thank you all for helping me. Actually I fixed the problem by myself. It's strange but true that if you create Varable to format date and then put variable in textfield, it does not work all times. Now I am getting data field directly as java.util.Date and formating textfield directly using simpleDateFormat. Please let me know if anyone needs actual XML code... Link to comment Share on other sites More sharing options...
yaghwin Posted December 11, 2008 Share Posted December 11, 2008 Hi Kuldip, can you share the jrxml with me?actually my issue is that i am getting the date with time e.g. 12/05/08 12:00:00 am and i want it like 12/05/2008 only.how can i achieve that.Post Edited by yaghwin bhatti at 12/11/08 12:50 Link to comment Share on other sites More sharing options...
C-Box Posted December 11, 2008 Share Posted December 11, 2008 Just try this as TextExpression (and set type to String) new SimpleDateFormat("MM/dd/yyyy").format($F{YourDateField}) Or use the pattern dialog within iReport to set the needed pattern for your date field hthC-Box Link to comment Share on other sites More sharing options...
yaghwin Posted December 12, 2008 Share Posted December 12, 2008 thanx a ton CBox... cheers 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