Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Date format issue
LetsBIRT
Hi,
Here is the issue: I have a simple query to pull the date. the date is in the format 8/27/2008 (create_date) with type "Date"
I am running a query like
select to_date(create_date) from blah blah.
When i put the data element in the report and run it, the display shows as
August 27, 2008 12:00 AM
I am not sure from where does it get the time ?? and when i see the Data type of the column in the Binding, it says Date Time. How can i get it to display as it is in the data base i.e. 8/27/2008, without using the formatdate on the data element.
Can you please help.
Thanks
Find more posts tagged with
Comments
mwilliams
Hi LetsBIRT,
Have you tried just going to the Binding tab of the Property Editor and change the Data Type to just Date, rather than Date Time?
mwilliams
Sorry. I didn't read all of your question. What I said before would just get rid of the time by changing the data type. It wouldn't help with the format issue.
The way to get it to display like MM/DD/YYYY will be to click on the data element in the report. Go down to the Property editor and go to the format DateTime section. In the drop down, choose the MM/DD/YYYY format. That should do it.
LetsBIRT
Thanks Michael, I was wondering if there is any other method, like i mentioned in my question
mwilliams
Again, trying to read too fast. Well, the first method will get rid of the time on the date at least. I'll look into the formatting issue.
LetsBIRT
Is there a way to change the format of the date on the Expression builder of a dynamic text?
mwilliams
LB,
If it's just for displaying, you could separate the month, date, and year out of the date with the functions getMonth(), getDate(), and getYear and then put them together month+"/"+date+"/"+year on your own.
getMonth() 0-11, so you'd have to add 1 to that.
getYear() returns the amount of years since 1900, so you'll have to add 1900 to it.
I'll look into whether there's an actual way to format the date differently in the dynamic text expression builder.
LetsBIRT
Thanks Michael.
cypherdj
You can also apply java formatting in the expression builder, eg:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
importPackage(Packages.java.text);
sdf = new SimpleDateFormat("dd/MM/yyyy H:m");
sdf.format(dataSetRow["myDate"], null, 0).toString();
</pre>
<br />
I haven't tested this code, but I've done the opposite quite a bit (convert a String of specified format to a Date).<br />
<br />
But if you only want formatting for display, there is a Format DateTime tab in the element properties editor, which allows you to apply custom formatting as well (see attached screenshot).<br />
<br />
Hope that helps,<br />
Cedric
mwilliams
That works in a dynamic text box if you delete the ", null, 0" part. I also deleted the ".toString()" part, but that probably doesn't make any difference.
cypherdj
Yes, my mistake on 2 accounts:
- there is a much simpler String format(Date) method (inherited from abstract class DateFormat),
- I didn't notice the specific requirement for dynamic text (is this essential if the only content of this text is a date? maybe an unbound data element would suffice?)
Regards,
Cedric
LetsBIRT
Thanks Cedric. The code in the expression builder was what i was looking for and it works.