Validate the date

I have to validate the date, using following rules. How I can validate.
�     Valid date
�     Not in the past
�     Not more than 56 days in the future

See DateFormat/SimpleDateFormat.parse()
http://java.sun.com/j2se/1.5.0/docs/api/java/text/DateFormat.html#parse(java.lang.String)
and Calendar.add()
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Calendar.html#add(int,%20int)
There are also before(), after(), and compareTo() methods in Calendar.
Message was edited by:
jbish

Similar Messages

  • How to validate the dates in the table control ?

    How to validate the dates in the table control ?
    Can I write like this ?
    LOOP AT it_tab .
    CHAIN.
    FIELD : it_tab-strtdat,it_tab-enddat.
    module date_validation.
    ENDCHAIN.
    ENDLOOP.
    Module Date_validation.
    ranges : vdat type sy-datum.
    vdat-sign = 'I'.
    VDAT-LOW = it_tab-STRTDAT.
    VDAT-HIGH = it_tab-ENDDAT.
    VDAT-OPTION = 'BT'.
    APPEND VDAT.
    WHAT CODE I have to write here to validate ?
    and If I write like this How can we know which is the current row being add ?
    It loops total internal table ..?
    Bye,
    Muttu.

    Hi,
    I think there is no need to put chain endchain.
    To do validation you have to write module in PAI which does required validations.
    Thanks
    DARSHAN PATEL

  • How to validate the date in my class

    Hi
    In my project with jsp and struts I need to validate the date field.
    So in the action class I want to validate the date that is the date is in dd/mm/year format?
    can anybody please give some idea to do this?
    Thank you so much.

    Here is a method that validates day/month/year using the Calendar class.
         public boolean validateDate(int day, int month, int year) {
              try {
                   Calendar cal = Calendar.getInstance();
                   cal.clear();
                   cal.setLenient(false);
                   cal.set(year, month-1, day);
                   // need to call getTime() to make the calendar compute/validate the date
                   cal.getTime();
                   return true;
              catch (IllegalArgumentException e) {               
                   return false;
         }

  • Validate the Date Time

    Does any java library class support to validate the date of the user input?

    Error index is concerned with the pattern not with the value.
    SimpleDateFormat test = new SimpleDateFormat("yyyy-MM-dd");
    ParsePosition p = new ParsePosition(0);
    p.setErrorIndex(-1);
    Date d=test.parse("2002-1130",p);  //does not match the pattern
    System.out.println(p.getErrorIndex()); // index other than -1 expected
    p.setErrorIndex(-1);  //  initialize
    d=test.parse("2002-11-31",p);// match the pattern but value invalid
    System.out.println(p.getErrorIndex()); //-1 expected

  • PL SQL Procedure to validate the data before inserting

    Hi All,
    I have a PLSQL procedure that validates the data and also inserts the data into the table. That procedure must be run to validate each row to be inserted. My doubt is how to reference that procedure within the interface of ODI.
    After reading some posts that mention the use of procedures, I think the best option is to call the procedure inside the knowledge module (inside a cursor that does a insert clause). Am I correct?
    As the KM's do a lot of verification and use temporary tables, I don't know what are the steps to be modified. Also, I would like to know if it's necessary to modified only the IKM or the LKM too.
    I'm using the IKM Oracle Incremental Update (PL SQL) and LKM Oracle to Oracle.
    Thanks.
    Luciene

    by validating data you mean looking up some table and see if it exists?
    If this is the case the you can implement this using a user function.
    If validation fails then you may put a -1 into the mapping.
    Then put a constraint on the target( say column is -1) and enable flow control.

  • When reading from the file validate the date  'DD/MM/YYYY'  format

    Hi,
    reading from the file ,validate the date format 'DD/MM/YYYY'.
    Thanks & regards
    venkata

    I suppose that you are writing a program in some programming language, probably PL/SQL. So, you can use TO_DATE function and handle the exception when it occurs.
    create or replace procedure tstdt
    as
      stdt varchar(10);
      dt date;
    begin
      stdt := '20/10/2006';
      dt := to_date(stdt);
       dbms_output.put_line('date is correct
    exception
    when others then
      dbms_output.put_line('Invalid Date');
    end;[],
    Miguel

  • Validate the data in the internal table with the date in selection screen

    Hi all,
    I want to validate the data in the internal table and get only the records with the input date in the selection screen.
    The date is in the select options and please let me know how to get the records only if it satisfies the input date in the selection screen.
    Regards,
    Shalem

    For Ex.
    SELECT-OPTIONS: S_DATE FOR VBAK-VDATU
    If you want to read one INTERNAL TABLE record
    READ TABLE it_tab(internal table name) WHERE vdatu(date field name in the internal table) = s_date
    If you want to move more then one
    LOOP AT it_tab WHERE vdatu = s_date.
    Take the field values in another table and append it. then end loop.
    you will get the records which only have the date in select option..
    If you want detail code give me internal table name and select option name i will write you the code.
    regards
    Yuvaram

  • Validate the data for SAP system

    How do you validate the data for SAP receiver system (RFC or IDOC adapter)?
    It is necessary to recognize does exists reference object or does field has the right value.
    Do you validate it in BPM or you handle  application/technical acnowlegment? Or Messaging monitoring is enough for your requirements.
    In case of ABAP Proxy will it enough to catch Fault Message in order to define what happens?

    Hi,
    there are two different kinds of validations:
    syntactical validation (length and data types of fields etc.) and semantical validations (correct customer in order, allowed number range etc.)
    From a theoretical point of view, only the first kind should be carried out in XI, all semantical validations should be part of the backend inbound processing. And indeed for IDocs and RFCs you will get according error messages in the backend. If you call proxies, you will need to code that yourself.
    In General i'd implement syntactical validations in XI, if more a necessary then XI already carries out (e.g. mandatory fields filled). For data validations i would rely on the backend, meaning for IDocs you should look into using ALEAUD IDoc, which will return any error messages during IDoc inbound processing. For RFCs you can have Exceptions defined which will translate to a negative application ACK.
    Regards
    Christine

  • How to validate the data in the table

    Hi Experts,
    My question is
    I am having a table control on my view. I need to validate the data entered by the user on the table
    and after validation i need to save the data into database table.
    Now my question is only related to Data Validation on table UI element.
    If the user enters 3 rows and if the 2nd and 3rd row are already existing,
    It should throw the message Entry already exists and the pointer should
    be at Row number 2 in this case.
    Similarly in the 2nd row i have a date field and if the user enters some character
    then it should throw an error message that Numeric values are only allowed and
    the pointer is placed in the 2nd row Date column so that it allows user to modify
    the wrong entry.
    Please advise.
    Regards,
    Chitrasen

    Hi,
    for validating user input in table , you have to get the entries inserted by user into an internal table using get_static_attribute_table and futher have your check using loop endloop.
    For date field, make the context attribute binded to date column as DATS. This would make sure the user inputs a valid date without your custom code.

  • How do u validate the data

    Hi
    I want to know Validate the data after extracting from R/3 to BW. Can any one of u please help me how should i go about this..
    If the annswers were given step by step briefly the full points wil be rewarded....
    waiting for the answrs

    Hi Kiran,
    Reconcilation:
    Reconcilation is the process of comparing the data after it is transferred to the BW system with the source system. The procedure to do reconcilation is either you can check the data from the SE16 if the data is coming from a particular table only or if the datasource is any std datasource then the data is coming from the many tables in that scenario what I used to do ask the R/3 consultant to report on that particular selections and used to get the data in the excel sheet and then used to reconcile with the data in BW . If you are familiar with the reports of R/3 then you are good to go meaning you need not be dependant on the R/3 consultant ( its better to know which reports to run to check the data ).
    I will give you a scenario to help you understand it better. Lets say BW extracts FI data from R/3. To make sure that all the records has been extracted from R/3 we can create a report in R/3 which will show the year-to-date balance of all the documents posted and we can create a BEx query on the BW cube which will also display the trial balnce. Any difference between the two balance will identify the records missing from R/3.
    Similary you can model other scenarios as per your requirement. If you are extracting from 2 or more different sources from R/3 then create a multicube on top of the individual cube and produce the report. You need to also create a similar report in R/3 as well.
    check this How to Doc:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/7a5ee147-0501-0010-0a9d-f7abcba36b14
    Pls do check the link's below
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/7a5ee147-0501-0010-0a9d-f7abcba36b14
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/biw/how%20to%20validate%20infocube%20data%20by%20comparing%20it%20with%20psa%20data
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/8c92d590-0201-0010-5aa0-ee7a993f295c
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/968dab90-0201-0010-c093-9d2a326969f1
    Question regarding Tranports?
    ****Assign Points If Helpful****
    Regards,
    Ravikanth

  • How can i validate the data in the control file?

    Consider that the SQLLoader reads the Input data File from the path and it loads the data into the tables based up on the descrition specified in the control File.
    First, the table to be filled is created:
    create table sql_loader_1 ( load_time date, field_1 Numeric, field_2 varchar2(10)
    Sample Control File :
    load_1.ctl
    load data
    infile 'load_1.dat' "str '\r\n'"
    insert into table sql_loader_1
    load_time sysdate,
    field_2 position( 1:10),
    field_1 position(11:20)
    Note that the positions 11 through 20 are loaded into field_1 and positions 1 through 10 into field_2. The field load_time is filled with the current time (sysdate) of the load.
    Here's the data. The name of the file (load_1.dat) had been specified with the infile statement in the control file.
    load_1.dat
    0123456789abcdefghij
    foo bar
    here comes a very long line
    and the next is
    short
    Here i want to validate the field_1 (Numeric Datatype) since the data file contains the character value (i.e)abcdefghij

    Good question for this forum:
    Export/Import/SQL Loader & External Tables
    Werner

  • Validate the Date and display the message

    Hi,
    Deposit Date:[yyyy/MM/dd]
    <td>
    <t:inputCalendar id="dtTo" required="false" value="#{processApplication.depositDate}"
                renderAsPopup="true" popupTodayString="today" popupWeekString="week"
             renderPopupButtonAsImage="true" popupDateFormat="yyyy/MM/dd" size="12"
             maxlength="10"  forceId="true"  popupButtonStyleClass="calendar"
             title="YYYY/MM/DD"    popupButtonImageUrl="../../images/calendar.gif">
    <f:convertDateTime type="date" pattern="yyyy/MM/dd" /></t:inputCalendar>
                                              </td>
                  <td ><h:message for="dtTo" /></font></td> Incase, when the user selects a date that is way back into the future or some date that is in 1900 ...I want to display a confirm dialog box saying " Are you sure of the date selected ? " .
    If yes..go ahead..if no give him another chance to select the date..
    I tried with having onclick in *<t:inputCalendar>* but it is not getting fired.
    Even if it gets fired, how can I check the condition that the Date entered is not the CurrentDate?
    Is there anyother better way to achieve this?
    Any help is appreciated.
    Thanks.

    <t:inputCalendar id="dtTo" required="false"
          value="#{processApplication.depositDate}" onchange="validatePastDate();"
          renderAsPopup="true" popupTodayString="today" popupWeekString="week"
          renderPopupButtonAsImage="true" popupDateFormat="yyyy/MM/dd" size="12"
          maxlength="10"     forceId="true"      popupButtonStyleClass="calendar"
          title="YYYY/MM/DD"     popupButtonImageUrl="../../images/calendar.gif">
    <f:convertDateTime type="date" pattern="yyyy/MM/dd" /></t:inputCalendar>
    function validatePastDate() {
       var ob = document.getElementById('form1:dtTo'); //not sure what you there
    When I looked in the view source of the page...it is using id="dtTo" as its id.
    Thanks.

  • How to validate the date in alv List

    Hi,
    How to write the code for date validation in alv.
    for ex
    i have to recieve the data in between any two months such as
    jan- feb,
    june-july,
    aug-sep,
    nov-dec,
    dec-jan,
    Could you plse explain me with some examples
    Thanking you
    Ravi Kumar

    I did not understand your requirement fully...but this code will give you date range for any two months..
    depending up on date you've supplied...
    DATA : date LIKE sy-datum,
           date_low LIKE sy-datum,
           date_high LIKE sy-datum.
    date = sy-datum.
    CALL FUNCTION 'MONTH_PLUS_DETERMINE'
      EXPORTING
        months  = '-1'
        olddate = date
      IMPORTING
        newdate = date_low.
    date_low+6(2) = '01'.
    CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
      EXPORTING
        day_in            = date
      IMPORTING
        last_day_of_month = date_high.
    WRITE :/ date_low.
    WRITE :/ date_high.

  • To validate the date in Unix using Oracle

    sqlplus /nolog <<EOF > /dev/null
    CONNECT $ORAUID/$ORAPWD
    WHENEVER SQLERROR EXIT 1
    SELECT TO_DATE('$DATE_INPUT', '$DATE_FORMAT') FROM DUAL;
    EOF
    if [ $? -eq 1 ]; then
    echo "Error: Wrong Date Format - $DATE_INPUT"
    exit
    fi

    You can get the date from the first internal table along with the posnr and calculate date calculations u an use RP_CALC_DATE_IN_INTERVAL    or  RE_ADD_MONTH_TO_DATE and again read the data with posnr and calculated date in the loop.
    Reward points if helpful

  • Is there any FM to validate the DATE input in selection screen?

    Hi Experts,
    The Z prog. does hv a field in selection screen, with name of enter_date_as_YYYYMM.
    So, user has to enter the vaue(inturn DATE) as YYYYMM, say 200807.
    1) So, YYYY valid range shuld be 1960-2099 only, if not, throw ERROR message
    2) MM range is obvoiusly 01-12, else ERROR message
    3) if user enters July as 7, prog. need to take it as 07
    so, instaed of coding to validate these, Is there any FM to meet my requirement?
    thanq

    Hi Srinivas,
    You can see the sample code mentioned below. It will throw those errors which u mentioned. Even you can change the logic as u required. This is just for your information...
    parameters: P_date(6) type n  obligatory.
    DATA: p_len TYPE i.
    at selection-screen.
    if ( p_date4(2) lt '01' or  p_date4(2) gt '12' ) .
      MESSAGE e400(ZCA_GENERAL) WITH 'Date format is wrong enter only YYYYMM'.
    elseif ( p_date0(4) lt '1960' or p_date0(4) gt '2099' ).
    MESSAGE e400(ZCA_GENERAL) WITH 'Date format ( Year 1960-2099 ) is wrong enter only YYYYMM'.
    endif.
    Regards,
    Naveen Veshala

Maybe you are looking for

  • "itunes has stopped working" after downloading album artwork??

    For years I've avoided ipod and itunes like the plague...but about 2 weeks ago I gave in. I got an ipod touch and installed itunes. Everything was fine - until this afternoon when I clicked on find album artwork in itunes. After itunes finished going

  • How to change the column header in XsltListView webpart

    I have a XsltListView webpart. By default it displays the column name in the header. How do I change the header and give a friendly name? I am able to change the header, if I click on header and position the cursor at the right spot and change. But s

  • Transferring a DVD to the Desk top and then downloading to Kindle Fire

    I want to transfer some of my DVD films to my Kindle Fire; can I do this by using the DeskTop DVD Drive first to copy to a store on the computer and then downlaodng to a Kindle, I am not technically dexterous so would like a detailed guide p[lease if

  • MacBook Pro Finder

    Why, each time I start up the MacBook Pro, do I get a bouncy "finder" icon on the bottom menu bar and a message : The last time you opened Finder, it unexpectedly quit while reopening windows. Do you want to try to reopen its windows again? I don't e

  • Searching  for lost files in Time Machine

    I save all of the E-mail messages to and from selected friends. I had thousands of such messages in the MAIL folder that was labeled, "Local E-mail (I also have a similar file entitled "Overseas E-mail)". Anyway, one moment, my entire "Local E-mail"