Comparing 2 dates .. urgent

Hi All,
     I am trying to compare 2 dates ( Calendar objects ) and not able to get the desired result. Here is the sample code
Calendar date1 = Calendar.getInstance(); // 1st date
date1.setTime( mdy4Format.parse( "07/31/2002" )); //mdy4Format is SimpleDateFormat
Calendar todayDate = Calendar.getInstance(); // 2nd date
if ( todayDate.after( date1 ) )
do something here....
else
do something
This should return false if both dates are same.
The problem is in hour:min:ss part. For date1 these all are 00:00:00 but for todayDate there is current time(e.g. 10:40:49 )
If I print the two dates using
System.out.println("today date = "+todayDate.getTime() ) ;
System.out.println("end date = "+ date1.getTime() ) ;
I get the following output for above print statements..
today date = Wed Jul 31 10:40:49 PDT 2002
end date = Wed Jul 31 00:00:00 PDT 2002
I JUST WANT TO COMPARE DATES ONLY AND NOT TIME FOR THOSE DATES
Any help is appreciated...
Thanks
vinod

Are you getting the inputted date as a String? You can just use,
if (yourDateFormat.format(new Date()).equals(stringDate)) {
  return "these string dates are equal"
else
  return "these string dates are not equal"where 'yourDateFormat' is your DateFormat instance and 'stringDate' is the date you are comparing against the current Date ... ... there are several ways to complete this need, but you need to remember that default date and calendar instances will be initialized to the current system time, e.g. they will have hour and minute values. If you want to ignore those values when resolving comparisons you either have to a) write your own Comparator to ignore the values or b) use a format instance to format them into 0 hour and 0 minute values.

Similar Messages

  • How to compare date between 2 file?

    hi there...
    is there any possibility to compare date between 2 file and the file that is latest to open?
    thank you

    i need help urgently..... i type tis code
    <%
    String file = ("C:/");
    File f = new File(file);
    String [] fileNames = f.list();
    File [] fileObjects= f.listFiles();
    %>
    <UL>
    <%
    for (int i = 0; i < fileObjects.length; i++) {
    if(fileObjects.lastModified()){
    %>
    <LI>
    <a href="<%= fileNames[i %">"><%= fileNames[i] %></A>
    <%
    %>
    my purpose is to list out all the file in the folder but not to the user just for the system to check all the files than when i click a link it will open the latest file
    Message was edited by:
    n_dilah</a>

  • Compare data in R/3 with data in a BW Cube after the daily delta loads

    Hi Friends,
    How can I compare data in R/3 with data in a BW Cube after the daily delta loads? Are there any standard procedures for checking them or matching the number of records?

    Hi Sunil,
    If you want to check the records daily instead of checking the data in R/3 manually ......
    You can try this...
    If you have staging DSO(level 1) that means whatever data is in source system load it to Staging DSO without any routines or any modifications.
    Now load this DSO data to Cube or DSO(level 2) as per your requirement with routines etc.
    Now Staging DSO contains Source system data.
    Now the level 2 Cube or DSO contains BW data with some modifications.
    Now create a Multiprovider based on level 1 and level 2 data targets.
    Now create a report on which keyfigures you want to test the data.
    In Multiprovider there is a field called 0infoprovider in data packet dimension.
    you can drag this infoprovider to the columns and restict your keyfigures with level 1 and level 2 data targets.
    In the first column you can see the level 1 DSO data ( source system data),in the 2nd column you can see the BW data.
    Now create a formula which gives the diffrence b/n level 1 and level2.
    that is R/3 data - BW data.
    If the diffrence is zero both R/3 and BW data are same.
    if the diffrence is not eqaul to zero check whether any routine is there or not.

  • Comparing data b/w biw and oltp

    hi
    Could some one can halp me how to compare data between biw and oltp system.which has been extracted.
    Thank for your precious time spent to help me in learning.
    Thanks,
    Jagadeesh

    Jagadish,
    It is not always all extracted data are coming from one standard table and comparison is easy. most of the time from multiple tables. There are couple of things you can do.
    1. If you know any R3 functionals you can inquire about reports available that produce the same kind of column groupings.
    2. If no one exists or do not get much help from them, and if you have SQ01 access in R3 you can create a query to bring the same columns fromcorresponding tables (This is a harder because you need access and need to findout from where data is coming from though info is available in help.sap.com).
    3. more practical would be select a small subset of data, with right filters in your selection columns of the info package and extract data, at the same time use the same selection in RSA3 (R3 side) to extract data and compare. This should tell you whether what you have in R3 is matching with the extracted data.
    4. After your transformations you can compare the same with your info provider (cube or ODS) contents as well.
    hope this helps,
    Award points if useful.
    Alex (Arthur Samson)

  • Comparing data in different resultsets

    Hi everybody!
    I am working on an web application involving some EAI, as a requirement i need to compare data from two different sources (databases to be precise) and fill a XML based on certain rules. I wish to know if there is a way to compare two ResultSet objects (with almost similar data) directly, or the only way to do is compare each value seperately.
    Also please suggest from efficiency point of view if its viable to store data from resultSet to a certain struc kind of object and then comparing, as it would involve lots of overhead compared to directly comparing the two resultsets.
    TIA
    Abhishek

    i have to compare various columns of each row and assign flags in output xml as to note if data is inconsistant, though i am taking measures so as to get the rows in the same order in both result sets, but the primary purpose of this comparison is indeed to check data integrity between both the sources.

  • Table_comparison - how to compare data at a high level

    Hi,
    I have to do data validation at a high level between two tables that I am loading.
    I am trying to use table_comparion transform but the problem is that my target table is at a much lower level than at which I want to compare data. So it has many more columns (both key and data fields) than what I want to compare.
    Does the output of query transform ( which I am using as input into table_comparion) be in the exact same format as comparion table? If not, then can somebody suggest me something else.
    Or how can I compare output of two query transforms ?
    Thanks,
    Saurabh Bansal

    Dear Saurabh,
    Not sure if you have already got the solution to this. If yes please close the thread.
    If not, i would suggest you can use the validation rule to compare the two tables and then based on the PASS or FAIL result can check what needs to be done on the output.
    Do post back if you have got the solution or you need any furthur help or else close the question.
    regards,
    Den

  • Compare data from a table

    Hello, I am trying to compare data from one and the same table. In short I have:
         NAME     DTM     CHARGE
         Atanas     8/18/2012 9:33:23 AM     100
    Atanas     8/18/2012 9:33:23 AM     101
         Niki     8/18/2012 9:33:43 AM     200
         Niki     8/17/2012 9:34:10 AM     100
    Niki     8/18/2012 9:33:43 AM     201
         Niki     8/17/2012 9:34:10 AM     101
         Atanas     8/17/2012 9:34:29 AM      50
    Atanas     8/17/2012 9:34:29 AM      51
         Joro     8/18/2012 12:10:12 PM 400
         Joro     8/17/2012 12:10:21 PM 300
    Joro     8/18/2012 12:10:12 PM 401
         Joro     8/17/2012 12:10:21 PM 301
    And I want to sum CHARGE for each DTM for each NAME and present the difference in an additional column, the output should be like that:
    NAME     DTM     CHARGE DTM CHARGE DIFFERENCE
         Atanas     8/17/2012 9:33:23 AM     101 8/18/2012 9:33:23 AM 201 - 100
    Niki     8/17/2012 9:33:23 AM     201 8/18/2012 9:33:23 AM 401 - 200
    Joro     8/17/2012 9:33:23 AM     601 8/18/2012 9:33:23 AM 801 200
    the DTM will be always /sysdate - 2/ and /sysdate - 1/,
    Thanks in advance!

    It is not clear what you are trying to do, but it looks like:
    with sample_table as (
                          select 'Atanas' name,to_date('8/18/2012 9:33:23 AM','mm/dd/yyyy hh:mi:ss am') dtm,100 charge from dual union all
                          select 'Atanas',to_date('8/18/2012 9:33:23 AM','mm/dd/yyyy hh:mi:ss am'),101 from dual union all
                          select 'Niki',to_date('8/18/2012 9:33:43 AM','mm/dd/yyyy hh:mi:ss am'),200 from dual union all
                          select 'Niki',to_date('8/17/2012 9:34:10 AM','mm/dd/yyyy hh:mi:ss am'),100 from dual union all
                          select 'Niki',to_date('8/18/2012 9:33:43 AM','mm/dd/yyyy hh:mi:ss am'),201 from dual union all
                          select 'Niki',to_date('8/17/2012 9:34:10 AM','mm/dd/yyyy hh:mi:ss am'),101 from dual union all
                          select 'Atanas',to_date('8/17/2012 9:34:29 AM','mm/dd/yyyy hh:mi:ss am'),50 from dual union all
                          select 'Atanas',to_date('8/17/2012 9:34:29 AM','mm/dd/yyyy hh:mi:ss am'),51 from dual union all
                          select 'Joro',to_date('8/18/2012 12:10:12 PM','mm/dd/yyyy hh:mi:ss am'),400 from dual union all
                          select 'Joro',to_date('8/17/2012 12:10:21 PM','mm/dd/yyyy hh:mi:ss am'),300 from dual union all
                          select 'Joro',to_date('8/18/2012 12:10:12 PM','mm/dd/yyyy hh:mi:ss am'),401 from dual union all
                          select 'Joro',to_date('8/17/2012 12:10:21 PM','mm/dd/yyyy hh:mi:ss am'),301 from dual
    select  nvl(s1.name,s2.name) name,
            s1.dtm,
            s1.charge,
            s2.dtm,
            s2.charge,
            s2.charge - s1.charge diff
      from      (
                 select  name,
                         dtm,
                         sum(charge) charge
                   from  sample_table
                   where dtm >= trunc(sysdate) - 1
                     and dtm <  trunc(sysdate)
                   group by name,
                            dtm
                ) s1
            full join
                 select  name,
                         dtm,
                         sum(charge) charge
                   from  sample_table
                   where dtm >= trunc(sysdate)
                     and dtm <  trunc(sysdate) + 1
                   group by name,
                            dtm
                ) s2
              on s1.name = s2.name
    NAME   DTM           CHARGE DTM           CHARGE       DIFF
    Atanas 17-AUG-12        101 18-AUG-12        201        100
    Niki   17-AUG-12        201 18-AUG-12        401        200
    Joro   17-AUG-12        601 18-AUG-12        801        200
    SQL> SY.

  • Comparing data from two tables

    My PL/SQL is very limited, however, I need to write some code that compares data stored in two different Oracle tables and then writes the differences to a third table. Both tables have primary keys that I will use to ensure I am comparing like for like. These tables could be large.
    Any help on the best way to do this, or any code examples would be very appreciated.

    One fairly efficient way of doing this is with set operators. The following code is untested - but looks right ;). It also assumes you want to know the provenance of the rows; if not, just zap the literal from each SELECT statement.
    INSERT INTO diff_tab SELECT * FROM
      ( (SELECT 'tab1nottab2' AS provenance, t1.col1, t1.col2 FROM tab1 t1
         MINUS
         SELECT 'tab1nottab2', t2.col_a, t2.col_b FROM tab2 t2)
         UNION ALL
         (SELECT 'tab2nottab1', t2.col_a, t2.col_b FROM tab2 t2
          MINUS
          SELECT 'tab2nottab1', t1.col1, t1.col2 FROM tab1 t1)
    /Cheers, APC

  • How to compare date which is greatest date

    iam new to sql
    how to compare date which date is greatest date with example
    can i use to_char to compare date
    SELECT eno, ename, GREATEST (TBLE.MAX1, TBLE.MAX2) recent_date "
                   FROM (SELECT TBLA.eno, TBLA.ename, "
                   MAX (TO_CHAR (TBL.date1, 'MM/DD/YYYY HH24:MI') "
                   ) MAX1, "
                   MAX (TO_CHAR (TBL.date2, 'MM/DD/YYYY HH24:MI') "
                   ) MAX2 "
                   FROM dual TBL, dual2 TBLA
    in above query if any one of the date having null value then recent_date is showing 'null'
    and also it showing wrong value
    example
    date1='08-22-2009' and date2='01-23-2010' then it showing wrong recent_datel ike='08-22-2009'
    as according my knowledge it is comparing with month it sholud not be like this wat i have to do pls explain with example my o/p should come for recent_date like =''01-23-2010''
    Edited by: user9112274 on Aug 27, 2010 5:31 AM

    Hi,
    there are numerous ways to compare dates, i give you some examples:
    with data_Sample as
    (select to_date('01-jan-2001','dd-mon-yyyy') d1, to_date('01-mar-2002','dd-mon-yyyy') d2, to_date('03-feb-2002','dd-mon-yyyy') d3 from dual)
    select greatest(d1,d2,d3) from data_Sample
    GREATEST(D1,D2,D3)
    3/1/2002
    with data_Sample as
    (select to_date('01-jan-2001','dd-mon-yyyy') d1 from dual union all
    select to_date('01-mar-2002','dd-mon-yyyy')   from dual union all
    select to_date('03-feb-2002','dd-mon-yyyy')  from dual)
    select max(d1) from data_Sample
    MAX(D1)
    3/1/2002
    declare
    d1 date :=to_date('01-jan-2001','dd-mon-yyyy');
    d2 date :=to_date('01-jan-2001','dd-mon-yyyy');
    begin
    if d1>d2 then
    dbms_output.PUT_LINE('d1 greater than d2');
    else
    dbms_output.PUT_LINE('d1 less or equql than d2');
    end if;
    end;
    output:
    d1 less or equal than d2now concerning your question:
    >
    can i use to_char to compare date
    >
    If you have date data types : don't convert them.
    if you have no choice, use something like:
    if to_char(d1,'YYYYMMDD') > to_char(d2,'YYYYMMDD') then
    else
    end if;Take care when you convert a date into a char format it becomes string comparison (with all it implies) (It's the reason why i've use an explicit mask format).

  • How to compare date and time together

    Hi,
    How to compare Date and Time together?
    For example in a database table there are two fields rundate and runtime.  I want to compare these two with perticular date and time in the program.  Like, I want to pull all the records where the records's date and time are less than a perticular date and time in the program.
    Hope the question is clear...
    Thanks.
    Kavita

    Hi Kavita
    There is no as such Date and Time Comparision FM in Standard SAP  But You can define your own like this
    <b>FUNCTION ZAV4_COMPAREDATETIME.
    ""Lokale Schnittstelle:
    *"  IMPORTING
    *"     REFERENCE(DATE1) TYPE  DATS
    *"     REFERENCE(TIME1) TYPE  TIMS
    *"     REFERENCE(DATE2) TYPE  DATS
    *"     REFERENCE(TIME2) TYPE  TIMS
    *"  EXPORTING
    *"     VALUE(TWOISMORETOPICAL) TYPE  C
      twoismoretopical = ''.
      if date2 > date1.
        twoismoretopical = 'X'.
      else.
         if date2 = date1 and time2 > time1.
           twoismoretopical = 'X'.
         endif.
      endif.
    ENDFUNCTION.</b>
    Regards
    Mithlesh

  • How to compare date with char

    hi
    i am having date from and date to feilds in my overtime element.i want to do the validation on these dates the the dates do not overlap or duplicated.the input value date from and date to are stored in database as varchar2 in the format yyyy/mm/dd 00:00:00. Now if i am trying to compare entered date with these dates i am getting literal does not match format string or date picture ends before....Can any body tell me what to do.
    Regards

    user10502390 wrote:
    hi
    i am having date from and date to feilds in my overtime element.i want to do the validation on these dates the the dates do not overlap or duplicated.the input value date from and date to are stored in database as varchar2 in the format yyyy/mm/dd 00:00:00. Now if i am trying to compare entered date with these dates i am getting literal does not match format string or date picture ends before....Can any body tell me what to do.
    RegardsPoint a) VERY BAD IDEA storing dates as VARCHAR2 on the database. It will only lead to corrupt data in the future.
    Point b) When comparing dates, you should compare them as DATE datatype as the database knows how to do comparisons against DATES. If you try and compare them as VARCHAR2 then you will most likely end up with incorrect comparisons.
    If you must have varchar2 storing of your dates/times (there's absolutely no reason to though)... you want...
    TO_DATE(:entered_date,'YYYY/MM/DD HH24:MI:SS') BETWEEN TO_DATE(DATEFROM,'YYYY/MM/DD HH24:MI:SS') AND TO_DATE(DATETO,'YYYY/MM/DD HH24:MI:SS')
    e.g.
    TO_DATE('20080815 13:23:33','YYYY/MM/DD HH24:MI:SS') BETWEEN TO_DATE(DATEFROM,'YYYY/MM/DD HH24:MI:SS') AND TO_DATE(DATETO,'YYYY/MM/DD HH24:MI:SS')

  • How manage two numbers files in the same screen to compare data

    Hello,
    I have two - 2 numbers files that I want to compare data between them in the same screen, How can I do that? Like in Excel you can compare two differente files in the same screen with the option windows cascade or something like that.
    Please Help Me.....

    First, turn off the abomination that is called "Full Screen" -- ported from the iPhone, land of tiny screens and single tasks.
    Then resize the first window to take up half the screen and place it on the left. Open the second spreadsheet and resize its window and place it on the right.
    Compare.

  • How to compare data between two tables?

    Hi,
    My team is trying to develop a SAP data migration tool (DMT) using ABAP.
    One of the functionalities in the DMT is to validate the data in the staging area against the loaded SAP data.
    The tables in the stagin area are customer tables (i.e. user-defined tables starting with Y, Z).
    How do I compare the data in the staging area against data that are loaded into SAP tables? Are there some built-in SAP functions to do this? Or, are there some better ways of doing this (e.g. instead of comparing against data in the SAP tables, we compare with some INTERNAL tables)?
    Any help would be greatly appreciated, thanks!

    Hi Kian,
    Use <b>SCMP</b> transaction to compare data between two tables and you can not use this for comparing internal tables.
    Thanks,
    Vinay

  • How to compare dates using javascript?

    Hi,
    I have to compare dates using javascript. The dates are in format "mm/dd/yy" for eg "10/09/06".
    I have written a script to compare the dates but the problem I 'm facing is with the year.
    For example if I compare "10/09/06" with "10/04/98", then "10/04/98" is coming out to be greater than "10/09/06" because it is considering year "98" to be greater than "06".
    Please advice/suggest.
    Thanks in advance...

    Dude, you're here in a Java forum, not in a Javascript forum. Those are two entirely different languages.
    The answer in Java is to use java.text.SimpleDateFormat to convert String to Date and use java.util.Date and/or java.util.Calendar to compare dates.

  • How to compare dates between two items

    Hello all,
    I am trying to compare dates in two items.
    The first item is a computation P45_PAGE_LOADED_TIME
    select sysdate from dual;
    This essentially keeps track of when the user opened the form. They are accessing data that may become obsolete while they are in the form.
    So we have a dynamic action that finds the last_update date from a table. This field is of type date. It is placed in a text field called P45_STATUS.
    We then have a notification which we want to fire when P45_PAGE_LOADED_TIME is before P45_STATUS. We tried the following condition
    declare
    least_date date;
    begin
    SELECT LEAST(TO_DATE(:P45_STATUS),TO_DATE(:P45_PAGE_LOADED_TIME)) into least_date
    from dual;
    if least_date = to_date(:P45_STATUS) then
    return false;
    else
    return true;
    end if;
    end;
    Any guidance would be most appreciated.
    Thanks

    Maybe your better off putting your anonymous block into a plsql function.
    A function that you can test. If it works in plsql then you must call it in APEX.
    I kinda get a headache when I see that least, to_date, to_date query (although I've seen worse :p)
    Make it like:
    create or replace function fun_least_date(in_status in varchar2,
                                                               in_page_loaded_time varchar2) return boolean
    is
      l_status date;
      l_page_loaded_time date;
      least_date date;
      l_return boolean;
    begin
      l_status := to_date(in_status, 'FORMAT MASK!!!');
      l_page_loaded_time := to_date(in_page_loaded_time, 'FORMAT MASK!!!!');
      least_date := least(l_status, l_page_loaded_time);
      if least_date = l_status then
        l_return := false;
      else
        l_return := true;
      end if;
      return l_return
    end fun_least_date;If your sure that your function is correct then use it as a condition for your dynamic action.
    Regards
    Nico
    ps: I haven't tested that function. Be aware that you most correctly enter the format mask you use in APEX. Also before APEX may know about these variables you should set a dynamic action on your items to always submit their value to the server when they change!!!

  • Compare date in SQL statement

    yup.. how can i compare date in SQL statement??
    pls give me a completed example.

    I'd think this is a formatting problem. Why not try:
    PreparedStatement ps = myConnection.prepareStatement(
    "SELECT * FROM Receipt WHERE to_date(Date) > ? ");
    ps.setDate(1,TodayDate);
    ResultSet rs = ps.executeQuery();
    HTH,
    Ken

Maybe you are looking for

  • Error in adding a group in ESSCMD

    <p>hi i am having this error message when i tried to add thisgroup</p><p>the ESSCMD was</p><p><span style=" color: #0000ff;"><b>IMPORT_GROUP,Australia_NZ,<br><MEMBERS><br>User name1,2,2<br>User name2</b> <b>,2,1<br>User name3</b> <b>,2,1<br>User name

  • Help moving mail from old hard drive to new installaion...

    I need to import all my mail from my original hard drive (in the second bay) to my new installation of Tiger on a new drive. I've got the new setup of Mail working fine. Can anyone point me to the steps required to safely import my original mail? Bot

  • Adobe 8.1.2 crashes PDF; Can't read PDF anymore Mac OS 10.4.11 PPC

    Ever since Adobe 7 and Mac OS 10.4.9 I've been updating/installing and still crashes on PDF reads from within Browsers or Adobe itself. I have an iMac 800 17" (Mac OS 10.4.11 with OS 9.2 PPC) recently maxed RAM 1Gb has backup eDrive by TechTool Pro.

  • VEPVG Table Updation

    Is anybody aware of how exactly VEPVG table gets updated ? Functionally VEPVG gets updated when we create an order with some schedule line data. But is anybody aware of the include/program where exactly VEPVG table gets populated ?? Also i believe th

  • Bizzarre non-deterministic run-time behavior.

    This is an attempt to coninue a thread that fell into the Archived Forums category after a year of inactivity. That thread can no longer be updated. This post is merely to note that the bug encountered in http://forum.java.sun.com/thread.jspa?threadI