Problem in sorting with date

Hi,
I have a requirement of sorting a column which displays date or a comment. Because of the presence of comment in some of the rows, the data type is not maintained as Date but as String.
That is cause of problem as the dates are getting sorted as per the String rules.
Could anyone suggest an approach of sorting strings with date??
Many Thanks,
Anagha

Hello Anagha!
Try to this code.
class MyComparator implements Comparator {
     public int compare(Object o1, Object o2) {
     IWDNodeElement element1 = (IWDNodeElement) o1;
     IWDNodeElement element2 = (IWDNodeElement) o2;
     Date date1 = new Date(element1.getAttributeAsText("Your name of Attribute"));
     Date date2 = new Date(element2.getAttributeAsText("Your name of Attribute"));
     return date1.compareTo(date2);
And just use it for your node, like this
    I"YourNode"Node node = wdContext.node"YourNode"();
    MyComparator myComparator = new MyComparator();
    node.sortElements(myComparator);
I hope it helps!
Message was edited by:
        Vitali Bashko

Similar Messages

  • Report Problem. Sort by Date?

    Hello all.
    I simply need to column sort by date, the problem is that the date needs a format mask.
    So I obviously do the following:
    SELECT to_char(SYSDATE, 'DD/MM/YYYY') FROM dual
    The problem is, it uses it as a CHAR.
    If I do
    SELECT to_date(to_char(SYSDATE, 'DD/MM/YYYY'),'DD/MM/YYYY') FROM dual
    It removes the format mask, any ideas?
    Sam

    Hi Sam,
    as Mike suggested, go to the "Column Attributes" of your report column and set the property "Number / Date Format" to DD/MM/YYYY
    In your SQL statement you just select the date column without any type conversion.
    What does it do?
    For the sorting, the Oracle database can do the sorting with the original date type. So you will get the correct ordering and after APEX has read the value it will apply the defined format mask and display it the way you like it. So APEX will do the TO_CHAR for you.
    Patrick
    My APEX Blog: http://inside-apex.blogspot.com
    The ApexLib Framework: http://apexlib.sourceforge.net
    The APEX Builder Plugin: http://sourceforge.net/projects/apexplugin/

  • Song order on ipod problem ( only sorted as date added)

    Basically what the title states. I just got a new Ipod (30G) and I just finished putting 1000+ songs on it, it was hard work but i finally got it. Yet I found out that my ipod is doing to the same things my other one was doing, Instead of sorting the songs in Alphabetical order by Artist in my playlist, it will only sort it by date added instead.
    I put my songs manually instead of syncing and Im not about to reorganize all my songs on Itunes for this problem.
    Is there anyone who can help me?
    Thanks.
      Windows XP  

    I'm not letting this question die out here.
    Any help is appreciated.
    thanks.

  • Oracle OCI: Problem in Query with Date field

    Client compiled with OCI: 10.2.0.4.0
    Server: Oracle9i Enterprise Edition Release 9.2.0.4.0
    The problematic query is:
    SELECT CODIGO FROM LOG WHERE TEL = :telnumber AND DATE_PROC = '05-JUL-08'Table description:
    SQL>describe LOG;
    TEL NOT NULL VARCHAR2(15)
    CODIGO NOT NULL VARCHAR2(20)
    DATE_PROC NOT NULL DATEAs simple as it might look, when executed directly on the server with SQLPlus, it returns a result, but when executed from the app that uses OCI, this query returns OCI_NO_DATA always. In the beginning, the date value was also a placeholder, but I found out that even giving a literal like '05-JUL-08' didn't work. I have tried the following:
    <ul>
    <li>I've tried the basics: querying the DB from the client does work. It's this one that gives me trouble</li>
    <li>The query: SELECT CODIGO FROM LOG WHERE TEL = :telnumber does work</li>
    <li>Executing: ALTER SESSION SET NLS_DATE_FORMAT="DD-MM-YYYY"; before the query in both the server and the client. Same result: server returns data, client OCI_NO_DATA</li>
    <li>Tried changing DATE_PROC format, combining this with the use of TO_DATE(). Same result.</li>
    <li>Searched, searched, searched. No answer</li>
    </ul>
    I'm a bit desperate to find an answer, would appreciate any help and can provide as many further details as needed. Thanks.
    Edited by: user12455729 on Jan 15, 2010 5:59 AM. -Formatting-

    Hi,
    I've recreated your table and populated with your data.
    I've run your select using OCILIB on a 10gR2 (client and server) and the codes runs fine and give expected results.
    So the problem must resides in your code.... (i don't think it can be a OCI bug)
    Here is the ocilib code :
    #include "ocilib.h"
    int main(void)
        OCI_Connection *cn;
        OCI_Statement *st;
        OCI_Resultset *rs;
        char msisdn[100] = "11223344";
        char datetime[100] = "";
        if (!OCI_Initialize(err_handler, NULL, OCI_ENV_DEFAULT))
            return EXIT_FAILURE;
        cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT);
        st = OCI_StatementCreate(cn);
        OCI_Prepare(st, "SELECT "
                        "  CODIGO_BANCO "
                        "FROM "
                        "  VTA_LOG "
                        "WHERE "
                        "  TELEFONO = :msisdn AND "
                        "  FECHA_PROCESO = TO_DATE(:datetime, 'YYYYMMDDHH24MISS')");
        OCI_BindString(st, "msisdn", msisdn, sizeof(msisdn)-1);
        OCI_BindString(st, "datetime", datetime, sizeof(datetime)-1);
        strcpy(datetime, "20080705162918");
        OCI_Execute(st); 
        rs = OCI_GetResultset(st);
        OCI_FetchNext(rs);
        printf("%s\n", OCI_GetString(rs, 1));
        strcpy(datetime, "20080705062918");
        OCI_Execute(st); 
        rs = OCI_GetResultset(st);
        OCI_FetchNext(rs);
        printf("%s\n", OCI_GetString(rs, 1));
        OCI_Cleanup();
        return EXIT_SUCCESS;
    }Output is :
    BancoOne
    BancoTwoi recreated your data with
    create table VTA_LOG
         TELEFONO          VARCHAR2(15) NOT NULL ,
         CODIGO_BANCO     VARCHAR2(20) NOT NULL ,
         FECHA_PROCESO     DATE NOT NULL
    insert into VTA_LOG values ('11223344', 'BancoOne',  to_date('20080705162918', 'YYYYMMDDHH24MISS'));
    insert into VTA_LOG values ('11223344', 'BancoTwo', to_date('20080705062918', 'YYYYMMDDHH24MISS'));
    commit;Regards,
    Vincent

  • Problem Export tables with data pump

    Hi,
    I want to export a 300 tables with datapump. But a received this message:
    ORA-39001: invalid argument value
    ORA-39071: Value for TABLES is badly formed.
    when i put only half of the tables i have neither any problem and it works ..
    anyone know this problem, i need to put all this tables to export?
    Thanks in advance.

    the file (*.dat) semble of this:
    DIRECTORY=PUMPDIR
    DUMPFILE=MyFile.dmp
    LOGFILE=MylogFile.log
    TABLES= User.Mytbale:partition1_0
    User.Mytbale:partition1_1
    User.Mytbale:partition1_2
    User.Mytbale:partition1_3
    OtherUser.Table:partition1_1
    in order 300 tables

  • Sorting with date added list

    ****0,
    I was wondering if there was a way to sort by Album, but at the same time by Date Added.
    Sometimes when I add multiple albums at once into Itunes, they do not load in the correct order and then subsequently modifying the individual files from each album is more difficult to do.
    So, anyway to search both Date Added and view the album in order at the same time?
      Windows XP  

    How about creating a smart playlist using the criteria "Date Added" -- or using the existing "Recently Added" smart playlist -- then sort that smart playlist by Album.

  • Problem with DATE in Interactive Report

    Hello,
    In Interactive Report when I click on the header of any column with DATE datatype, nothing happens due to Javascript error:
    Line: 2
    Char: 14838
    Error: Expected identifier, string or number
    Code: 0
    Click on any other column works perfectly as well as sorting by DATE column from Action Menu.
    I tried to set different format masks for my DATE column and for Application Date Format, but it didn't help.
    Finally I found out that this error disappeared when in properties of my DATE column in "List of Values" section I set "Report Filter Date Ranges" = 'Past' instead of 'All'. In this case I get the list with values "Last 5 Years", "Last 2 Years", etc, but not with "Next Hour", "Next 2 Hours", etc...
    Can someone help me on this issue, because this functionality might be usefull and also it's not very convinient to change this property for all date columns in all Interactive Report.
    By the way, my database version is 9.2.0.5 - maybe it can cause such problem?
    Best regards,
    Vladimir

    Hi Marco,
    1) French Canada (fr-ca)
    2) This filter works
    More informations about the error when I call the function gReport.controls.widget():
    &lth;div id="apexir_DT" style="text-align: center;" onclick="gReport.controls.widget(this.id)"&gth;Date de naissance&lth;/div&gth;
    *************POST*************
    flowid     48579
    p_flow_step_id     5
    p_instance     1412541985987586
    p_request     APXWGT
    p_widget_action     SORT_WIDGET
    p_widget_mod     CONTROL
    p_widget_name     worksheet
    x01     5775894815382747091
    x02     5775899227924757464
    x03     apexir_DT
    *************RESPONSE*************
    {"dialog":{"id":"1966481623126322611","hide":["apexir_info","apexir_computation"],"coltype":"DATE","filter"
    :false,"uv":true,{"dialog":{"uv":true,"row":[{"V":"Failure<br />ORA-20001: get_dbms_sql_cursor error
    ORA-00923: FROM keyword not found where expected"}]}}
    Louis-Guillaume
    Homepage: http://www.insum.ca
    Blog: http://insum-apex.blogspot.com

  • The timesheet creation failed, because of problems with the project I server or with data validation

    Hi,
    One of my user is facing issue in creating new time sheet,
    "The time sheet creation failed, because of problems with the project server or with data validations".
    This issue is coming to only few members out of 10000 members.
    Note: For the same user, can able to do in other machines. only the problem in his machine. Have ran the office diagnostics, but still the problem persists.
    Is any add-on's/any settings need to update in IE. Could any one please help me on how to fix this issue?
    Many thanks in advance.

    I would check the compatibility settings in IE etc, or try another browser (chrome, safari etc.)
    Ben Howard [MVP] | web |
    blog | book

  • Problem with Date Picker and wwv_flow_item.date_popup()

    I have a Report based on the HTMLDB How-To “Build Tabular Forms for Multi-Row Operations”
    This is my code:
    select
    X.RRIT_UID,
    X.DOS,
    X.CPT_CODE,
    X.MOD,
    X.DX_CODE,
    X.CHARGES,
    X.UNITS
    from
    (select
    htmldb_item.text(1,RRIT_UID) RRIT_UID,
    wwv_flow_item.date_popup(2,null,RRIT_DATE_OF_SERVICE) DOS,
    htmldb_item.text(4,RRIT_SUBMIT_SERVICE_CODE,6) CPT_CODE,
    htmldb_item.text(5,RRIT_SUBMIT_MODIFIER,3) MOD,
    htmldb_item.text(6,RRIT_ATT_DIAG_CODE,6) DX_CODE,
    htmldb_item.text(7,RRIT_BILLED_CHARGES,9) CHARGES,
    htmldb_item.text(8,RRIT_UNITS,3) UNITS
    from
    RRIT_REPRICE_ITEM
    where
    RRRR_UID = :P5_RRRR_UID
    union all
    select
    htmldb_item.text(1,null) RRIT_UID,
    wwv_flow_item.date_popup(2,null,null) DOS,
    htmldb_item.text(4,null,6) CPT_CODE,
    htmldb_item.text(5,null,3) MOD,
    htmldb_item.text(6,null,6) DX_CODE,
    htmldb_item.text(7,null,9) CHARGES,
    htmldb_item.text(8,null,3) UNITS
    from
    dual)
    X
    My problem is when I run the page and select a date from the Pop-Up calendar I get this error:
    Line 10
    Error: ‘opener.document.forms.0.f02.0’ is null or not an object
    I know it is something to do with data formats and the fact that I do not fully understand the use of wwv_flow_item.date_popup().

    Hi DK,
    It is a WD Java application, Backend is ABAP (MM module).
    The UI is input field, where the context attribute type is Date, So its been changed to Date Picker.
    The problem is when the user runs the WD application in Portal, The calendar format is being changed for some users. That is for few users the Week starts with Monday and for few users the week starts with Sunday.
    I need all the users to have Monday as the First day of the week.
    Please let me know, what will be solution for this.
    Since I haven't done anything in regard to date, it is a simple Date format.
    Thanks & Regards,
    Palani

  • Having a problem with dates when I send my numbers doc to excel. dates are all out and that they have to cut and paste individual entries onto their spreadsheet. Any idea how I can prevent this

    having a problem with dates when I send my numbers doc to excel. dates are all out and that they have to cut and paste individual entries onto their spreadsheet. Any idea how I can prevent this.
    I'm using Lion on an MBP and Numbers is the latest version

    May you give more details about what is wrong with your dates ?
    M…oSoft products aren't allowed on my machines but I use LibreOffice which is a clone of Office.
    When I export from Numbers to Excel and open the result with LibreOffice, the dates are correctly treated.
    To be precise, dates after 01/01/1904 are correctly treated. dates before 01/01/1904 are exported as strings but, as it's flagged during the export process, it's not surprising.
    Yvan KOENIG (VALLAURIS, France) mardi 3 janvier 2012
    iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
    My iDisk is : http://public.me.com/koenigyvan
    Please : Search for questions similar to your own before submitting them to the community
    For iWork's applications dedicated to iOS, go to :
    https://discussions.apple.com/community/app_store/iwork_for_ios

  • Problem with Date Parameter

    Hi
    I am new to reporting services/report designer but have created a number of simple reports with Parameters using data from queries that have worked but I have a problem with this using Date and Time. 
    I am using MS Visual Studio 2008 (BIDS) and our SQL Server is Windows Server 2008 R2
    I need to allow the users of the report to choose a start date and an end date
    The Start Dates are held in a field called PhaseStartDate
    The End Dates are held in a field called PhaseEndDates
    I have tried multiple ways to try to get this to work with no success and with the latest attempt I get the message  
    "An error occurred during local report processing. The definition of the report 'JKVoidLoss' is invalid. The report parameter 'StartDate' has a default value or ValidValue that depends on the report parameter"Startdate". Forward dependancies
    are not valid"
    I will explain how I set up the Startdate. The EndDate is set up the same with the relevant values and fields.
    I created a new data source called StartDate. Under QUERY I have Select PhaseStartDate from QLHRA_VoidPhases. This runs okay when tested in Query designer and RUN.
    Under FIELDS I have Field name as PhaseStartDate and Field Source as PhaseStartdate
    Under PARAMETERS I have Parameter Name as PhaseStartDate and Parameter Value as [@StartDate]
    I set up a Parameter called StartDate with Data type as Date/Time
    Under Available Values I selected Get values from a query with Dataset being StartDate, Value field being PhaseStartdate and Label field being PhaseStartDate
    There are no Default Values
    I have tried moving the parameters up and down using the blue arrows under report data. I have tried multiple different methods to resolve this by changing values in the Properties screens.
    I also tried removing the DataSets and just using the Parameters with default settings. in preview, this ran the report but no matter what dates where entered the output was always the same.
    Any assistance will be greatly appreciated as I have spent hours on this so far
    Regards
    John

    Hi
    I am new to reporting services/report designer but have created a number of simple reports with Parameters using data from queries that have worked but I have a problem with this using Date and Time. 
    I am using MS Visual Studio 2008 (BIDS) and our SQL Server is Windows Server 2008 R2
    I need to allow the users of the report to choose a start date and an end date
    The Start Dates are held in a field called PhaseStartDate
    The End Dates are held in a field called PhaseEndDates
    I have tried multiple ways to try to get this to work with no success and with the latest attempt I get the message  
    "An error occurred during local report processing. The definition of the report 'JKVoidLoss' is invalid. The report parameter 'StartDate' has a default value or ValidValue that depends on the report parameter"Startdate". Forward dependancies are not valid"
    I will explain how I set up the Startdate. The EndDate is set up the same with the relevant values and fields.
    I created a new data source called StartDate. Under QUERY I have Select PhaseStartDate from QLHRA_VoidPhases. This runs okay when tested in Query designer and RUN.
    Under FIELDS I have Field name as PhaseStartDate and Field Source as PhaseStartdate
    Under PARAMETERS I have Parameter Name as PhaseStartDate and Parameter Value as [@StartDate]
    I set up a Parameter called StartDate with Data type as Date/Time
    Under Available Values I selected Get values from a query with Dataset being StartDate, Value field being PhaseStartdate and Label field being PhaseStartDate
    There are no Default Values
    I have tried moving the parameters up and down using the blue arrows under report data. I have tried multiple different methods to resolve this by changing values in the Properties screens.
    I also tried removing the DataSets and just using the Parameters with default settings. in preview, this ran the report but no matter what dates where entered the output was always the same.
    Any assistance will be greatly appreciated as I have spent hours on this so far
    Regards
    John
    As I understand what you need to do is to just remove parameter from the dataset query for populating the date values and then it should work fine
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Problem with date conversion

    I have read some topics about it, but still have problem :-(((
    When I insert data, I don't have any problem with a date. It looks like this:
         Statement stmt = con.createStatement();
              stmt.executeUpdate("BEGIN " +
                        "INSERT INTO employee VALUES (" +
                        "employee_t(idnum.nextval,'John','Double'," +
                        "to_date('21.01.1975','DD.MM.YYYY'), 20000))" +
                        "END;"); Now I am trying to update, and get the error:
      String query = "BEGIN UPDATE employee SET " +
    "first_name ='"+getJtxtfldFirst_name().getText()+"', "+
    "last_name = '"+getJtxtfldLast_name().getText()+"', "+
    "date_of_birth = to_date('1982-03-11','YYYY-MM-DD'), "+
                                     "END; ";
    Statement stmt = con.createStatement();
                   int rs = stmt.executeUpdate(query);
                   stmt.close();The error:
    java.sql.SQLException: ORA-06550: line 1, column 149:
    PLS-00338: unable to resolve "DATE_OF_BIRTH" as a column or row expression
    ORA-06550: line 1, column 7:
    PL/SQL: SQL Statement ignoredI have tried different variants, tried to parse... Just can't find where I make the error.
    If I comment this line, with a date, there are no any exceptions.
    This code in sqlplus works fine.

    And besides that, you don't need to wrap your SQL
    with the PL/SQL "BEGIN" and "END" tags; why invoke
    the PL/SQL parser if you're not using any PL/SQL
    features?
    I suspect your underlying problem is that the column
    isn't actually named "date_of_birth".You are quete right. It was my faulf. There was a field date_of_birthday. The oracle could say it more preciesly.
    With the statement it works fine also.
    Thank you for the answer and sorry for disturbing, I have forgotten to update the database and was sure I copied the new files... But updated the old one.

  • Problem with date format when ask prompt web-intelligence

    Bo XIR2 with 5 SP. Instaled on Windows 2003 with support Russian.
    Inside BO every labels, buttons - use russian. But when invoke web-report and Prompt appear there is problem with date format.
    Looks like korean format of date 'jj.nn.aaa H:mm:ss'.  I see system settings of date in Win .. everything right
    What i have to do?
    Where i can change format date for bo?

    GK, try this...
    decode(instr(packagename.functionname(param1 ,param2),'2400'), 0, to_date(to_char(to_date(rtrim(packagename.functionname(param1 ,param2),'(PT)'), 'Month dd, yyyy "at" hh24mi'),'mm/dd/yyyy hh24mi'),'mm/dd/yyyy hh24mi'),
                                                                      to_date(to_char(to_date(rtrim(packagename.functionname(param1 ,param2),'(PT)'), 'Month dd, yyyy "at" "2400"')+1,'mm/dd/yyyy "0000"'),'mm/dd/yyyy "0000"'))-Marilyn

  • Problem with Date format

    Got one more problem Merilyn and Radhakrishnan...
    Regarding the soln y provided me earler with the thread "Problem with date format"...
    What is happening is....I am able to change the 2400 to 0000 but when it is changed from 2400 on jan 1st to 0000 the hour is changing but not the date....the date still remains as jan 1st instead of jan 2nd....
    Eg: Jan 1st 2400 -- changed to -- jan1st 0000
    instead of jan 2nd 0000
    Could you please help me in this issue...
    Thanks,
    GK

    GK, try this...
    decode(instr(packagename.functionname(param1 ,param2),'2400'), 0, to_date(to_char(to_date(rtrim(packagename.functionname(param1 ,param2),'(PT)'), 'Month dd, yyyy "at" hh24mi'),'mm/dd/yyyy hh24mi'),'mm/dd/yyyy hh24mi'),
                                                                      to_date(to_char(to_date(rtrim(packagename.functionname(param1 ,param2),'(PT)'), 'Month dd, yyyy "at" "2400"')+1,'mm/dd/yyyy "0000"'),'mm/dd/yyyy "0000"'))-Marilyn

  • Problem with date calculation

    I am a rookie in SAP i have a small problem with date.Do we have any function module to find out the first day in a month if we give out the system current date ?? Pls help me out.

    Hi,
    As Ganesan told,you can do.
    Here is the sample code.
    data v type sy-datum.
    data d type DTRESR-WEEKDAY.
    v+6(2) = '01'.
    v4(2) = sy-datum4(2).
    v0(4) = sy-datum0(4).
    CALL FUNCTION 'DATE_TO_DAY'
      EXPORTING
        date          = v
    IMPORTING
       WEEKDAY       = d.
    write d.

Maybe you are looking for

  • Report Filter Prompt not working on Homepage

    Hi, We created a custom report on the home page for everyone to see. It is a task list and should prompt you for parameters. When you run it from the report screen, it prompts you for parameters. When you click the link from the home page, it runs wi

  • How to grab system time in nano seconds?

    Is there any way to grab the system time in nano seconds? Thanks!

  • How to append input array parameter to a conditon in where clause

    CREATE OR REPLACE PROCEDURE file_upload(p_array_code IN DIAG_CODE,p_desc_code IN DIAG_CODE_DESC,p_code_result OUT DIAG_CODE_TABLE) IS v_count NUMBER; v_range1 VARCHAR2(8); v_range2 VARCHAR2(8); l_count pls_integer := 0; l_diag_code_table1 DIAG_CODE_T

  • Using HP Scan Pro 7.4.5 To Create Multiple-page PDFs

    I can scan in the first page fine, but when prompted as to whether I have any further pages of my document to add, HP Scan Pro won't give me a preview of subsequent pages. Any tips? Andy

  • SDK Installation

    hello all i downloaded SDK, i need a step by step instalation procedure for it and how can i apply these services on my system. i am using callmanager v.4.1 and cisco unity connection version 1.1 your reply will be appreciated regards