This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Date Formatting

Phil - Wednesday, February 24, 2010 11:46 AM:

I am having an issue with the way dates are returned when I perform a query for a property of type "Date" outside of Innovator.

It looks like it is stored in the database as a datetime data type, but the way it is returned is quite ugly.

Consider the following code:

 Item qryItem = this.MyInnovator.newItem(strItemType, "get");
 qryItem.setAttribute("select", "issue_date");
 qryItem.setProperty("id", strID);
 Item results = qryItem.apply();

The date is returned in the following format: "2008-03-12T00:00:00"

Yick. I have tried a couple things thus far: 

1. Changing the pattern property to short_date_time for the issue_date field.

2. Trying to inject some sql : qryItem.setAttribute("select","convert(varchar, issue_date, 102)")

Neither of these methods did anything, and actually the second method didn't work at all. I know I have 2 options that will work, I am just trying to make use of IOM.  I know I can use the direct SQL method, and I know I can format it in my code...but I would like a cleaner way of doing it if it exists.

RobMcAveney - Wednesday, February 24, 2010 12:29 PM:

The "ugly" format for dates is actually quite standard.  This has to do with internationalization (i18n) and localization (l10n).  Date values go "over the wire" in a unambiguous neutral format and are then localized on the client side.  Remember that 1/3/2010 is January 3rd in the U.S. but March 1st in Germany, so formats like that won't work.  IOM provides methods to go between the neutral format and the localized format.  Try something like this:

Innovator inn = this.getInnovator();
I18NSessionContext i18n = inn.getI18NSessionContext();
string localDate = i18n.ConvertFromNeutral(this.getProperty("created_on",""),"date","short_date_time");


Boro - Wednesday, February 24, 2010 9:32 PM:

Hi Phill

You can find the document written about date time property on Aras site.

See following contents -> "5.1.3 Locale Neutral Data Formats"