date format
Hi,
i have a problem regarding the date sorting. What is happening is am gettingthe date in the format ddmmmyyyy taking this am date am formatting it in to string but wat i observed in the sorting is it formats the date in the alphebatical order? can any1 help me out?
shanky
February 13,
Alex (ActiveWidgets)
February 13,
Hi alex,
I tried with what u said but it was asking to check the method am using the Version1. Please help its urgent !!!!!!
anand
March 8,
I use these functions for sorting
function string(text){return text;};
function number(text){return Number(text.replace(/[ ,%$]/gi, '').replace(/\((.*)\)/, '-$1'))};
function datetime(text){var oData = new Date(); return Number(Date.UTC(text.substr(6, 4),text.substr(3, 2),text.substr(0, 2),text.substr(12, 2),text.substr(15, 2)))}
var toValue = [number,string,string,date];
obj.setDataProperty('value', function(i,j){return toValue[j](obj_data[i][j]);});
document.write(obj);
You could use them and rewrite the datetime function (the text.substr.... part)
Good luck
Rekcor
March 8,
The correct code for above post
function string(text){return text;};
function number(text){return Number(text.replace(/[ ,%$]/gi, '').replace(/\((.*)\)/, '-$1'))};
function datetime(text){var oData = new Date(); return Number(Date.UTC(text.substr(6, 4),text.substr(3, 2),text.substr(0, 2),text.substr(12, 2),text.substr(15, 2)))}
var toValue = [number,string,string,datetime];
obj.setDataProperty('value', function(i,j){return toValue[j](obj_data[i][j]);});
document.write(obj);
Good luck
Rekcor
March 8,
Hi Rekcor,
To be more specific my problem is as followed---
I have a grid developed as followed with the first row highlighted.
Type Date Subject
CR 08Mar2007 Sample
FL 08Mar2007 Test
CN 07Mar2007 Test
CR 06Mar2007 Sample
CM 06Mar2007 Test
CN 08Jan2007 Test
CN 08Jan2007 Test
When i click on the date column i get the sorting as------
Type Date Subject
CN 07Mar2007 Test
CR 06Mar2007 Sample
CM 06Mar2007 Test
CN 08Jan2007 Test
CN 08Jan2007 Test
CR 08Mar2007 Sample
FL 08Mar2007 Test
Please help me out as this is not the correct sorting. I guess we need to have the dispaly as-------
Type Date Subject
CN 07Mar2007 Test
CR 06Mar2007 Sample
CM 06Mar2007 Test
CN 08Jan2007 Test
CN 08Jan2007 Test
FL 08Mar2007 Test
CR 08Mar2007 Sample
THANKS IN ADVANCE!!!!!!!
anand
March 8,
You should convert your dates to numbers, as those are sortable. So if you manage to put your dates in the YYYYMMDD format, the sorting works well. Note: the conversion only has to take place before sorting, so the things displayed on the screen can be 08Mar2007 etc.
So how could we convert 08Mar2007 to YYYYMMDD? The only *small* probleem is the month, because it is a string, we have to convert is to a number:
var asMonths = new Array();
asMonths['Jan'] = 1;
asMonths['Feb'] = 2;
asMonths['Mar'] = 3;
etc.
Now the sort function becomes something like (haven't tested it):
function datetime(text){var oData = new Date(); return Number(Date.UTC(text.substr(7, 4),asMonths[text.substr(3, 2)],text.substr(0, 2)))}
Hope this helps
Rekcor
April 11,
An effective workaround,
capture your date format in raw date (ie, long type).
set the cell
<%for(i=0; i<length; i++ ){%>
obj.setCellValue(<%=dateTime%>,0,<%=i%>);
<%}%>
var str = new AW.Formats.String;
var numct = new AW.Formats.Number;
numct.setTextFormat("########");
obj.setCellFormat([numct, str, str, ...]);
obj.setSortColumn(0);
obj.setSortDirection("descending", 0);
This will work in any extreme condition
Sanjay Sharma
April 12,