AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sort Date

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
jeffsal@charter.net
Guest





PostPosted: Fri Aug 19, 2005 5:21 pm    Post subject: Sort Date Reply with quote



This sort function does not seem to work with my date format which is
1/01/2004 no leading 0 for month. Is there anything that could be
changed so it would sort properly. It is part of a Table Sort script
(sorttable.js) Thanks

function ts_sort_date(a,b) {
// y2k notes: two digit years less than 50 are treated as 20XX,
greater than 50 are treated as 19XX
aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
if (aa.length == 10) {
dt1 = aa.substr(6,4)+aa.substr(3,2)+aa.substr(0,2);
} else {
yr = aa.substr(6,2);
if (parseInt(yr) < 50) { yr = '20'+yr; } else { yr = '19'+yr; }
dt1 = yr+aa.substr(3,2)+aa.substr(0,2);
}
if (bb.length == 10) {
dt2 = bb.substr(6,4)+bb.substr(3,2)+bb.substr(0,2);
} else {
yr = bb.substr(6,2);
if (parseInt(yr) < 50) { yr = '20'+yr; } else { yr = '19'+yr; }
dt2 = yr+bb.substr(3,2)+bb.substr(0,2);
}
if (dt1==dt2) return 0;
if (dt1 return 1;

Back to top
Andrew Thompson
Guest





PostPosted: Fri Aug 19, 2005 5:42 pm    Post subject: Re: Sort Date Reply with quote



On 19 Aug 2005 10:21:01 -0700, [email]jeffsal (AT) charter (DOT) net[/email] wrote:

Quote:
This sort function does not seem to work with my date format which is
1/01/2004 no leading 0 for month. Is there anything that could be
changed so it would sort properly. It is part of a Table Sort script
(sorttable.js) ...

You have the wrong group, I'm afraid..
<http://www.physci.org/codes/javafaq.jsp#js>

--
Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"You can blow out a candle, but you can't blow out a fire. Once the flame
begin to catch, the wind will blow it higher."
Peter Gabriel 'Biko'

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.