jQuery Tablesorter - Sort by Date, 4 Month Intervals

catonthecouchproductions used Ask the Experts™

I am working on a table using the tablesorter jquery plugin for: http://goo.gl/ul4m3 and would like to show only the Apartments available in a four month range. I'm looking for a way to filter the date column with jQuery to show only the current month, whichever that may be, plus the next  three after that.

Any thoughts?


Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT Expert
Top Expert 2009
Something like

var start = new Date();
var end = new Date();
end.setMonth(end.getMonth()+4); // find the 5th month
end.setDate(0); // set it to the last day of the month before

$(".tablesorter tr td:nth-child(3)").each(function() { // 3rd cell
  var dateStr = $(this).text(); // 06-01-2012 - mm-dd-yyyy I assume
  var date = new Date(dateStr.replace(/-/g,"/")).getTime();
  if (date < start.getTime() || date > end.getTime()) {

Open in new window

However that does not re-zebra the lines so I suggest you hide or REMOVE the lines before activating the sorter
Thanks for the quick reply. Worked great. -Kyle

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial