How to compare a date with current date

I have 3 drop menus for a user to choose day, month and year. After the user submit the form, my system should be able to detect whether the date chosen has passed compared to TODAY's day. I thought I could compare the day, month and year as integers, but it sounds quite tedious with this integer combination. I wonder if there is any methods available to compare dates. I come to know that I can use something like Calendar.before(). Could anyone give me some idea?

I'm little confused with your suggestion since I'm new in Java and JSP. I hope you could give me some more hints. Anyway, I got this thing but couldn't really apply it:
public boolean before(Date when)
Tests if this date is before the specified date.
Parameters:
when - a date.
Returns:
true if this date is before the argument date; false otherwise.

Similar Messages

  • How to compare table data and table field

    Hi buddy,
        I have some question about how to compare table data and table field.
       1. I know there is one method:   CL_ABAP_UNIT_ASSERT=>ASSERT_TABLE_CONTAINS  , it use in unit test to compare the table data(A and B) , you can loop table A into structure A1, then use this mehtod it can compare whether table B contain structure A1.  but when I try to use this in main program it will dump.
              CL_ABAP_UNIT_ASSERT=>ASSERT_TABLE_CONTAINS(
                                                                                                        LINE    = A1
                                                                                                        TABLE = B ).
           Is there any method or FM can be used to compare the table data ?
        2. I also want to compare two table field , try to find out the different. How to realize this.
    Thank you for your sincerely answer.

    Hi Zongjie,
    What`s the difference, if you using loop A into wa_A, read table B into wa_B with all field, then compare with wa_A and wa_B.
    The question 2, seems no standard FM available here.
    Loop A into wa_A.
       Loop B into wa_B.
           if wa_A-field1 eq wa_B-field1.
           endif.
            if wa_A-field2 eq wa_B-field2. 
           endif.
       endloop.
    endloop.
    regards,
    Archer

  • How to Compare two Dates in java

    How to Compare two Date Field after getting the values from jTextField1.getText() and jTextField2.getText().

    Date d1=DateFormat.getDateInstance().parse(yourstring1);
    same for d2
    d1.compareTo(d2);
    could be that i misrememberd the exact naems of some functions or mixed up something in the equence of d1=

  • How to compare two dates that should not exceed morethan 3 years

    hi all,
    can you please tell me how to compare two dates( basically dates are string type)
    that should not exceed more than 3 years? in JAVASCRIPT
    Thanks in Advance.

    This is not a JavaScript forum.
    [*Google* JavaScript Forum|http://www.google.co.uk/search?q=JavaScript+Forum&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-GB:official&client=firefox-a]
    Good luck.

  • How to compare two dates to know which one is greater than oher?

    how to compare two dates to know which one is greater than oher?
    Please search before asking basic questions.
    Edited by: Rob Burbank on Mar 27, 2009 9:26 AM

    Hi,
    If thse to date fields are of same type u can directly compare like this.
    regards,
    Bharat.

  • Can anybody tell how to compare two documents with two pointers controlled with the same mouse

    can anybody tell how to compare two documents with two pointers controlled with the same mouse ??

    I saw what I need but in a game to find the differences between two photos (two screens, two pointers controlled by one mouse), and I need a program to make the same thing   (compare a chosen files)

  • How to compare a Date data with Current Year and Period Member on FIX

    Hi experts,
    I have a Project dim that each member is a Project (P01, P02...)
    and Account dim that stores information of the each Project (Name, Start date, Finished Date...)
    Finished Date member is in Date data type
    So how can write a IF condition below in order to compare Project Finished Date with Current Year and Period members on FIX
    FIX (@Descendants(Projects), Descendants(All Year), Descendants("Year Total")...)
    IF (@CURRMBR(Period)->@CURRMBR(Year) < Project->FinishedDate)
    Do something...
    Else
    Do something
    Please help me on this. Sorry for my bad grammar. Please ask if there is anything unclear
    Many thanks,
    Huy Van.
    Edited by: Huy Van on Jan 29, 2013 1:14 AM
    Edited by: Huy Van on Jan 29, 2013 2:24 AM
    Edited by: Huy Van on Jan 29, 2013 2:25 AM
    Edited by: Huy Van on Jan 29, 2013 6:04 PM

    Here is what I have done. Post for whom may concern later
    VAR FM; /* Finished Month of Project*/
    VAR FY; /* Finished Year of Project */
    VAR CM; /* Capture Current Month on FIX statments */
    VAR CY; /* Capture Current Year on FIX statments*/
    FIX ( @RELATIVE( "Year", 0), @RELATIVE( "Period", 0), @IDescendants( "Base Projects")....)
    FY = @ROUND( "TGHT"->"NA Contract"->"FY06"->"NA Period" / 10000, 0);
    FM = @MOD( @ROUND( "TGHT"->"NA Contract"->"FY06"->"NA Period" / 100, 0), 100);
    /* For FY13 return 13... */
    CY = @JgetDoubleFromString( @CONCATENATE( "20", @SUBSTRING( @NAME( @CURRMBRRANGE( Year, Lev, 0, 0, 0)), 2)));
    /* Set CM value based on currrent Period On FIX statement */
    IF ( @ISMBR( "Jan"))
    CM = 1;
    ELSEIF ( @ISMBR( "Feb"))
    CM = 2;
    ELSEIF ( @ISMBR( "Dec"))
    CM = 12;
    ENDIF
    IF ( CY < FY OR ( CY == FY AND CM < FM))
    Do something...
    ELSE
    Do something...
    ENDIF
    ENDFIX
    Edited by: Huy Van on Feb 19, 2013 11:10 PM
    Edited by: Huy Van on Feb 20, 2013 7:46 PM

  • How to compare Sale data with Previous data

    Hi Guys,
        Any one tell me how we will compare Sales data with Last year Sale data. Is there any T.Code or any kind of Report in the SAP. If available please suggest the same.
    Thanks & regards,
    Naveen Bhatia

    Hi Naveen,
    Did yo ucheck t-code SD01
    Regards
    Rohit.

  • How to compare delivery date in schedule lines and PGI in outbound delivery

    Hi,
    I want to create a report to monitor and compare different dates in sales and delivery process.
    One of my key figure is the comparison between date confirmed to the customer, that I can find in the schedule line of the sales order, and the actual goods issue date from the outbound delivery.
    But I can't succeed in making the link between delivery and schedule lines, means between LIKP and VBEP.
    Would you have any idea?
    Thank you.

    It seems there's no exact (table) connection / link between delivery item and schedule line item.
    Those who were searching for this thing (link / connection between delivery item and schedule line) were recommended to use FM "RV_SCHEDULE_CHECK_DELIVERIES".
    This FM calculates the delivered quantity for each schedule line, so it makes link between the delivery item and schedule lines - however if you check the code it's quite sophisticated...
    (if you put a breakpoint in the FM and display a SO in VA03, you can check how the parameters have to be populated with data).
    Schedule Line and Delivery Link
    Edited by: Csaba Szommer on Aug 5, 2011 12:03 AM

  • How to compare 2 dates in a JPA QL query

    hello all,
    how can i compare 2 dates in JPA QL ,?
    my idea was to convert the dates to String, and i used 'to_char',
    but i think it doesn't work in JPA QL;
    this is my query(it works in oracle but not in java) :
    Query q=em.createQuery("select sum(o.montant) from Operation o join o.codTransac t join o.codCaisse c where (t.sens='D')and (to_char(c.dateCaisse,'MM/DD/YYYY')=to_char(o.dateOp,'MM/DD/YYYY'))");
    can some one help me?
    thanks

    I don´t know if it´s the same case, but I had a similar problem and I`m posting here the way I solved it (maybe it isn´t the best solution but worked to me).
    I have to compare a date come from a web form (format dd/mm/yyyy) with a Timestamp data from DB (dd/mm/yy hh24:mi:ss).
    Solution:
    //String dateTo from web form
    //Substring here were used to get only dd/mm/yy from DB and ignore the hours
    ql.append(" SELECT o FROM Table o WHERE SUBSTRING(o.dateTime,1,8) = :end ");
    q = getEntityManager().createQuery(ql.toString());
    q.setParameter("end",convertStringToDateSimple(dateTo));
    //function used to parse the String date and return in an appropriate format expected in the above query
    public static String convertStringToDateSimple (final String source)
         final SimpleDateFormat format = new SimpleDateFormat("dd/MM/yy");
              String parsed = null;
                   try
                        parsed = format.format(format.parse(source));
                   catch (ParseException e)
                        throw new RuntimeException(e);
              return parsed;
    Edited by: user8947239 on 31/10/2011 10:58

  • How to compare 2 dates, on date and on time

    Hi,
    Can anyone explain me how I can compare 2 dates!
    I can compare them by date, but not by time.
    For example:
    Date1 = '2003-07-25 16:50:15.0'
    Date2 = '2003-07-25 14:20:48.0'
    I want to get the dates that are bigger than the date '2003-07-25 15:30:57.0', but I don't get any result.
    Normally I must get Date1 as result.
    This is because only the date is compared, not the time.
    If I ask the dates bigger than '2003-07-24 14:35:31.0' I get Date1 and Date2 as result!
    I want all the data where the foto_crea_date is bigger than the given date.
    I do this in my where-clause as followed:
    TO_CHAR(FOTO_CREA_DATE,'yyyy-MM-dd hh:mm') > '2003-07-24 06:10:15.0'
    and it works just fine for the dates, not for the time
    I hope someone can help me!!

    Hi,
    I tried to use to_date instead of to_char but than I get the following error!
    Return Error Message: JBO-27122: SQL error during statement preparation.
    Statement: SELECT FotoMain.FOTO_ID, FotoMain.FOTO_CDCM, FotoMain.FOTO_CONF, FotoMain.FOTO_COMP, FotoMain.FOTO_CLIENT, FotoMain.FOTO_CLIENT_GROUP, FotoMain.FOTO_DESCRIPTION, FotoMain.FOTO_PUBL, FotoMain.FOTO_PUBL_SITE, FotoMain.FOTO_ECMA_ID, FotoMain.FOTO_CREA_DATE, FotoMain.FOTO_EXCL, FotoMain.FOTO_MRKT, FotoMain.FOTO_ID || ', ' || FotoMain.FOTO_DESCRIPTION AS VIEW_ATTR FROM FOTO_MAIN FotoMain WHERE (FOTO_CREA_DATE >= TO_DATE('2003-07-24 16:15','yyyy-MM-dd hh:mm')) ORDER BY FOTOMAIN.FOTO_ID
    Error Message: ORA-01810: format code appears twice
    If tried also something else and it works just fine for the dates but still not with the time.
    I tried it as followed:
    String last = "2003-07-24 16:15";
    String wherelastlogin="TO_CHAR(FOTO_CREA_DATE,'yyyy-MM-dd hh:mm') >= '" + last + "'";
    Can anyone help me because I need to compare also the time?!

  • How to compare 2 dates in SQL Server 2000 DB using Java?

    How do you compare 2 dates in SQL Server 2000 DB using Java?
    Let's say we have two fields: Date Reported and Target Finish Date.
    Date Reported is 09-10-2004 09:55:55: PM
    Target Finish Date is 09-12-2004 11:59:59: PM
    What i want to happen is i want to convert both dates to days and get the difference of the two.
    can SQL Server 2000 DB do this?

    it doesnt wrk.
    ok here's what i did:
    iv tested a simple code for this case.
    I created a table name tblDate which has 3 columns namely date_ID, date_From (datatype datetime), date_To (datatype datetime).
    I inserted 1 row: date_ID has the value 1, date_From has the value 10/22/2004, and date_To has the value 10/24/2004.
    i run the java code below:
    int days = 0;
              String query = "SELECT date_From, date_To cast(date_From-date_To AS int) AS Diff FROM tblZoo WHERE date_ID = '1'";
              try
                   DBConnect db = new DBConnect();
                   db.openCon();
                   ResultSet rs = db.execute(query);
                   while(rs.next())
                        days = rs.getInt("Diff");
                   db.closeCon();                         
              catch (Exception ex)
                   System.out.println("Error on Execution: " + ex);
              return days;___________
    an error occurred: Error on Execution: java.lang.nullpointerexception

  • How to compare single value with multiple values

    In my query I have something like this:
    A.SOR_CD=B.SOR_CODE where A and B are 2 different tables. This condition is in the where clause. The column in table A has single values but some values in table B have multiple comma separated values (822, 869, 811, ..).  I want to match this single
    value on the left side with each of the comma separated values. Please let me know how will I be able to do it. The number of comma separated values on the right side may vary.

    Hi MadRad123,
    According to your description, you want to compare single value with multiple values in your query. Right?
    In this scenario, the table B has comma separated values, however those comma separated values are concatenated into a string. So we can use charindex() function to return the index of the table A value. And use this index as condition in
    your where clause. See the sample below:
    CREATE TABLE #temp1(
    ID nvarchar(50),
    Name nvarchar(50))
    INSERT INTO #temp1 VALUES
    ('1','A'),
    ('2','A'),
    ('3','A'),
    ('4','A'),
    ('5','A')
    CREATE TABLE #temp2(
    ID nvarchar(50),
    Name nvarchar(50))
    INSERT INTO #temp2 VALUES
    ('1','a,A'),
    ('2','A,B'),
    ('3','c'),
    ('4','A,C'),
    ('5','d')
    select * from #temp1 a inner join #temp2 b on a.ID=b.ID
    where CHARINDEX(a.Name,b.Name)>0
    The result looks like below:
    Reference:
    CHARINDEX (Transact-SQL)
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • How to compare 2 arrays with different operator options using parameters in Teststand

    Pls let me know how to compare 2 arrays using different operators like <= or >= or ==......

     I am using TS 2010. FYI
    ex:
    Array XX [ A_Temp,
                   B_Temp,
                   C_Oil Pressure,
                   D_Oilpressure,
    Note : A_Temp, B_Temp,C_Oil Pressure,D_Oilpressure all these parameters will be getting  numerical values (dynamically) from the simulink models and also in future I may need to add parameters to this array.
    Array YY [A_Temp_1,
                   B_Temp_2,
                   C_Oil Pressure_3,
                   D_Oilpressure_4,
    Note : A_Temp_1, B_Temp_2,C_Oil Pressure_3,D_Oilpressure_4 all these parameters will be getting  numerical values (dynamically) from the simulink models
    So my question :
    I would like to verify A_Temp >= A_Temp_1
                                B_Temp >= B_Temp_2
                                C_Oil Pressure  >= C_Oil Pressure_3  etc

  • How to compare the date value with the date datatype column?

    Hi,
    I am executed a query to get output for the particular date in two different database.
    I got output in one db environment, but in the another environment i didnt get the output.
    APP_DECISION_DATE column contains date datatype
    ex:
    SQL> select DECISIONED_STAGE_ID,DECISIONED_STAGE_USER_ID from naap10_application where APP_DECISION_DATE = TO_DATE('23-JAN-07',
    'DD-MON-YY'); 2
    DECISIONED_STAGE_ID DECISIONED_STAG
    2006060106 SYSTEM
    DATABASE - II
    SQL> select DECISIONED_STAGE_ID,DECISIONED_STAGE_USER_ID from naap10_application where APP_DECISION_DATE=
    TO_DATE('31-JAN-2007','DD-MON-RRRR') and application_id=2007010028552;
    no rows selected
    in the same db i got the output while i used the TO_DATE(APP_DECISION_DATE)
    SQL> select DECISIONED_STAGE_ID,DECISIONED_STAGE_USER_ID from naap10_application where TO_DATE(APP_DECISION_DATE)=
    TO_DATE('31-JAN-2007','DD-MON-YYYY') and application_id=2007010028552; 2
    DECISIONED_STAGE_ID DECISIONED_STAG
    2006060113 SYSTEM
    is it necessary to use TO_DATE function while i am using the data datatype column in the WHERE CLAUSE?
    Thanks in advance.
    siva

    Sorry & thanks sathish,
    Now i got the result.
    SQL> select DECISIONED_STAGE_ID,DECISIONED_STAGE_USER_ID from naap10_application where APP_DECISION_DATE BETWEEN TO_DATE ('31.01.2007 00:00:00', 'DD.MM.YYYY HH24:MI:SS') AND TO_DATE ('31.01.2007 23:59:59', 'DD.MM.YYYY HH24:MI:SS')
    2 and application_id=2007010028552;
    DECISIONED_STAGE_ID DECISIONED_STAG
    2006060113 SYSTEM
    ================================
    But one doubt,
    When i created the column with the date datatype how it gets the time value,
    And in one environment db i got the result but in another environment i dont get,
    Shall i want to change any session status of date?

Maybe you are looking for

  • How can i backup my iPod Touch 4g and save my apps onto a new hard drive without having to save onto the current hard drive first?

    How can i backup my iPod Touch 4g and save my apps onto a new hard drive without having to save onto the current hard drive first? My current hard drive is filled up and i'm going to buy a new, bigger hard drive. How can i change the save and backup

  • Issue in Production Core Schema of ATG 10.0.3

    Hi All, I tried to create a schema in Production Core from CIM. The schema created successfully and when I tried to import data , it finished up saying that "No Data to Import". In the table listing, none of the DCS tables are found. I am using ATG 1

  • Unable to install Oracle 11g R2 on Windows 8

    Hi All, I know this is a familiar post with quite a few users facing problems while trying to install Oracle 11g R2 on Windows 8 platform. Subsequently, there have been resolutions provided -  Hyperion Error of the Day: Oracle Database 11g Installer

  • How to convert Date format in Apex?

    Hi All, I have created a Date picker item in Apex as "dd-mm-yyyy", Now when they select this date picker it has to convert into "Day,Month DD, YYYY". I have trired like this but it is not wroking, can any one help me to get this to be done. Under the

  • Question re start up drives & disc utility under Lion

    My startup drive is slightly buggy (I hope only slightly) and I need to fix it with disc utility - I know I need to first startup from another drive. two questions: 1 - I have a backup drive (external USB) that's formatted with the 10.6.5 OS.  If I s