Register

Closed Thread

Junior Member

Join Date: Jun 2008
Posts: 3
 
06-26-2008, 12:48 PM
Question sort a non US date format field

Hi
Would appreciate any assistance with this situation. Have successfully got a table of data appearing and sorting - except that we are in the UK and we have a different date format - dd mm yyyy. The Spry javascript assumes the dates are US format - mm dd yyyy and therefore when we sort them it doesn't sort correctly. I am hoping that we have simply missed a setting - otherwise do we have to dive into javascript?!
John Martin is offline
Senior Member

Join Date: Dec 2007
Posts: 359
 
06-26-2008, 09:53 PM
Default

Hello, John!

We are a hosting company, and I would hazard a guess that you're inquiring about the Spry framework for AJAX from Adobe.

Here's a link to the Spry AJAX Framework Documentation - it should be the best place to look for more information (if you are, indeed, seeking assistance with Adobe's product).

... and here's a bit of Javascript code which will swap your dates around:

Code:
<script type="text/javascript">
var internationalDate = 'DDMMYYYY';
var usDate = internationalDate.substring(2,4) + '/' + internationalDate.substring(0,2) + '/' + internationalDate.substring(4,8);
alert(usDate); // Display the result of the script
</script>
Note: If you need to concatenate the date without any / characters, use the toString() method to ensure that the date's components are not added when the + operator is used.

Example:

Code:
var internationalDate = '31032008';
var usDate = internationalDate.substring(2,4).toString() + internationalDate.substring(0,2).toString() + internationalDate.substring(4,8).toString();
alert(usDate); // Display the result of the script
DanL@Spry is offline
Junior Member

Join Date: Jun 2008
Posts: 3
 
06-27-2008, 01:04 AM
Default Thank you kindly - a bit more help may get us there

I may need to be more specific - what you have suggested is good - so here goes. Imagine we have a table with lots of columns imported from an XML dataset, one of which is a date. In the US the date is formatted mmddyyy and Spry successfully sorts the date column beautifully - now imagine that the date is formatted ddmmyyyy - how can we inform Spry that the date format is non-US so that the sorting does not hiccup!

Thanks
John
John Martin is offline
Senior Member

Join Date: Dec 2007
Posts: 359
 
06-27-2008, 01:08 PM
Default

Aside from a very unreliable method (comparing the first two digits to determine whether they represent a number greater than 12 and then treating the date as though it were international), you will need to use some other item of data to denote whether the field's date is in US or international format.

My recommendation would be to convert the date into a timestamp or ISO-formatted date before it is touched by any Javascript - doing so will ensure a standard date format wherever the data is used at the small price of regularly converting the date for display.
DanL@Spry is offline
Junior Member

Join Date: Jun 2008
Posts: 3
 
06-27-2008, 02:20 PM
Default

Thank you Dan
Will give this a go!

John
John Martin is offline
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 09:01 PM. Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 VBulletin Skin by ForumMonkeys.