Converting input date alternative format

Hi,
I'm developing a screen form (not SQL Plus) in which I want the user to enter a date in any format and then convert it to another - for example,
User inputs - 02/03/2000
Form converts field from 02/03/2000 to 02-MAR-2000.
How do I do this ?
John

Do you want to allow many different formats or you want to allow the date entry in only one format always?
For example, if you decide that the date entry will be in the format of MM/DD/YYYY, then you can use
TO_DATE('02/02/2002', 'MM/DD/YYYY') to create a date type datatype from the input.
If you wanted to support multiple formats, then you would have to do some if-else logic to figure out the format in which
the user entered the date and use appropriate format within the TO_DATE function.

Similar Messages

  • FB for converting inputed period into period format of the user

    Hi All,
    my concern is to convert from to another period format.
    For example:
    in my user-profile is setted the following format:  DD/MM/YYYY
    what i do input is a period with format: DD.MM.YYYY
    Does a FB exists in BW that can help with this task?

    hi,
    do like this.
    code]DATA: V_DATE_IN(10) TYPE C,
    V_DATE_SAP TYPE SY-DATUM.
    V_DATE_IN = '01.01.2005.'.----------------------> ur input
    CONCATENATE V_DATE_IN+6(4) "<--for Year
    V_DATE_IN+3(2) "<--for month
    V_DATE_IN+0(2) "<--for Day
    INTO V_DATE_SAP.
    now V_DATE_SAP will have value like 20060101.
    pass the above to this FM.
    data:date_form type CHAR10.
    call function 'HRGPBS_HESA_DATE_FORMAT'
    exporting
    P_DATE = V_DATE_SAP   -
    > input date
    importing
    DATESTRING = date_form
    exceptions
    others = 1.[/code]
    date_from -
    >  DD/MM/YYYY fomat
    rgds
    Anver
    if hlped pls mark points

  • Date Format in Input Date Component

    Hi,
    I am using JDev 11.1.1.3.0. I have few Input Date component in the form. I need to display the selected date in upper case. Basically the month in upper case.
    Currently it displays '01-Aug-2012'. I need it to be displayed as '01-AUG-2012'.
    Tried adding format but still the month is displayed in initial caps. Really appreciate if someone can help me in fixing this issue.
    Thanks
    SR

    There is no format to archive this. Check http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html which give you all format patterns used by the inptutDate component.
    I have not tried this, but you should be able to use a converter, which you have to write yourself, to make the month uppercase.
    Writing your own converter is easy, for a tutorial check http://docs.oracle.com/javaee/5/tutorial/doc/bnaus.html
    Timo

  • To convert dec date 732,677 in to dd.mm.yyyy format

    Hi,
    i have to convert dec date 732,677 in to dd.mm.yyyy format .
    plz help me out
    its urgent
    regards,
    Nishu Gupta

    use this Fm
    CONVERSION_EXIT_INVDT_INPUT
    <b>CONVERSION_EXIT_INVDT_output.</b>
    i hope u r referring to Tcurr-gdatu.
    refer this code for the working ..
    data : date like sy-datum,
           date1(10) type c,
           val like sy-datum,
           datum(8) type n .
    date = sy-datum.
    write:/ date.
    concatenate date4(2) date6(2) date+0(4) into val.
    CALL FUNCTION 'CONVERSION_EXIT_INVDT_INPUT'
      EXPORTING
      input          = val
    IMPORTING
       OUTPUT        = datum.
    write:/'tcurrformat' datum.
    *clear val.
    CALL FUNCTION 'CONVERSION_EXIT_INVDT_OUTPUT'
      EXPORTING
        input         = datum   "----
    >pass this
    IMPORTING
        OUTPUT        = date1.
    write:/'normal format',  date1.
    Please close your previous threads.
    regards,
    vijay

  • How can i convert this data(00000000) into date format(yyyy-MM-dd)

    Hi,
    i am using this method to convert date format from string.
    public static string FormatDate(string inputDate, string inputFormat)
                System.DateTime date = DateTime.ParseExact(inputDate, inputFormat, null);
                string datepresent = DateTime.Now.Date.ToString("yyyy-MM-dd");
                return datepresent;
    its working properly,
    but when input data is like 00000000 i am getting error this is not valid.
    how can i convert this into date format any help..!

    Have you tried the above code:
    I can see it is working with both Date and DateTime destination nodes.
    Map:
    Functoid Parameters:
    Functoid Script:
    public static string FormatDate(string inputDate, string inputFormat)
    string datepresent;
    if (inputDate == "00000000")
    datepresent = "0000-00-00";
    else
    System.DateTime date = DateTime.ParseExact(inputDate, inputFormat, null);
    datepresent = date.ToString("yyyy-MM-dd");
    return datepresent;
    Input:
    <ns0:InputDateString xmlns:ns0="http://DateFormat.SourceSchema">
    <DateString>00000000</DateString>
    </ns0:InputDateString>
    Output:
    <ns0:OutputDate xmlns:ns0="http://DateFormat.DestinationSchema">
    <Date>0000-00-00</Date>
    </ns0:OutputDate>
    If this answers your question please mark as answer. If this post is helpful, please vote as helpful.

  • FM to convert the date in to the format in SU01

    hi,
    will u pls suggest the FM to convert the date in the format presented in SU01->Defaults.
    with respect to user the diffrent format may stored in the su01.
    kindly suggest.
    thanks.

    data: dat TYPE date,
           org TYPE date.
    This function module converts data from the sy-datum format to ddmmyyyy.
    CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'
      EXPORTING
        input         = sy-datum
    IMPORTING
       OUTPUT        = dat.
    write: sy-datum.
    write: dat.
    This function module converts data to sy-datum format.
    CALL FUNCTION 'CONVERSION_EXIT_PDATE_INPUT'
      EXPORTING
        input         = dat
    IMPORTING
       OUTPUT        = org
    write: org.
    You can change the user settings for date using the transaction SU01.

  • Convert a date in String format to a Date

    Hi,
    How can I convert a date in String format to a Date object?
    I have tried:
    import java.text.*;
    import java.io.*;
    import java.util.Date;
    import java.util.Locale;
    import java.sql.*;
    public class casa {
    public static Connection con = null;
    public static Statement s = null;
    public static String sql = null;
    public static String mydate = "01.01.2001";
    /** Creates a new instance of casa */
    public casa() {
    public static void main(String[] args) throws SQLException{
    try {
    DateFormat shortFormat = DateFormat.getDateInstance(DateFormat.SHORT);
    Date date = shortFormat.parse(mydate);
    //Open Database
    con = getConnection();
    s = con.createStatement();
    sql = "select date1 from table1 where date1 <= '"+date+"'";
    ResultSet rs = s.executeQuery(sql);
    while(rs.next()){
    String aba = rs.getString("datum");
    System.out.println("New Datum = "+aba);
    } catch (Exception ex ) {
    ex.printStackTrace();
    closeConnection(s, con);
    //Connection
    private static Connection getConnection() {
    Connection con = null;
    String user ="aouzi";
    String passe ="aouzi";
    String url = "jdbc:db2:EjbTest";
    try {
    //Datenbanktreiber laden
    Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
    //Verbindung herstellen
    con = DriverManager.getConnection(url,user,passe);
    }catch(ClassNotFoundException e){
    } catch(SQLException e){}
    return con;
    //close Connection
    private static void closeConnection(Statement s, Connection con) {
    try {
    s.close();
    } catch (SQLException e) {}
    try {
    con.close();
    } catch (SQLException e) {}
    I'm getting the following errors:
    COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0180N
    The syntax of the representation of a date/time of day value as character sequence is false. .SQLSTATE=22007

    I'm pretty sure it won't understand what date.toString() returns. If you know what format the database understands, you do it like this:
    SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yy"); // e.g. 18-Apr-02
    String datestring = sdf.parse(date);
    and use that instead of date in your sql string. Some databases understands it if you do
    "to_date('18-Apr-02')"
    so you could include that in your sql string as well..
    You could also try to make it a java.sql.Date and hope your jdbc driver knows how to convert it to a string that the database understands if you don't know the format:
    con = getConnection();
    PreparedStatement ps = con.prepareStatement("select date1 from table1 where date1 <= ?");
    ps.setDate(new java.sql.Date(date.getTime()));
    ResultSet rs = s.executeQuery(sql);

  • How to convert the date time from MM-DD-YYYThh:mm:ss to YYYY-MM-DDThh:mm:ss format

    Hi All,
    I have a requirement in my project like to convert the date time from one format to another.my situation is like to convert the date time from MM-DD-YYYThh:mm:ss to YYYY-MM-DDThh:mm:ss format. I am using the soa suite 11.1.1.6.
    Can any one suggest me how to convert in the BPEL transformation.
    Thanks,
    Sanju.

    Hi Sanju,
    Store the date to be converted into a variable viz. dateVar. Now, process an expression in assign as: xp20:format-dateTime($dateVar,'[Y0001]-[M01]-[D01] [h]:[m01]:[s01]').
    Regards

  • Convert Epoch Date Time to Date Time format

    I am trying to convert Epoch Date time in GMT to Human Readable Date time format in UTC. I used the one below but it returns just the date in GMT but how can get datetime in UTC ?
    select To_Char( To_Date( '01.01.1970 06:00:00','DD.MM.YYYY HH24:Mi:Ss') + STARTIME / 86400,'DD.MM.YYYY HH24:Mi:ss') FROM HQ_AVAIL_DATA_RLE;
    I refered a couple of forums and applied everything, but still I wouldn't get the timestamp.
    Please note that i'm looking for datetime stamp, not just the date.
    Thanks in advance!
    Edited by: 830754 on Jan 27, 2011 11:18 AM
    Edited by: 830754 on Jan 27, 2011 11:19 AM

    Works for me. I see date and time (submitted 1000 for STARTTIME):
    select To_Char( To_Date( '01.01.1970 06:00:00','DD.MM.YYYY HH24:Mi:Ss') + 1000 / 86400,'DD.MM.YYYY HH24:Mi:ss')
    from dual
    TO_CHAR(TO_DATE('01
    01.01.1970 06:16:40Or do you mean something else?

  • How to convert BLOB data into string format.

    Hi,
    I have problem while converting blob data into string format.
    for example,
    Select dbms_lob.substr(c.shape.Get_wkb(),4000,1) from geotable c
    will get me the first 4000 byte of BLOB .
    When i using SQL as i did above,the max length is 4000, but i can get 32K using plsql as below:
    declare
    my_var CLOB;
    BEGIN
    for x in (Select X from T)
    loop
    my_var:=dbms_lob.substr(x.X,32767,1)
    end loop
    return my_var;
    I comfortably convert 32k BLOB field to string.
    My problem is how to convert blob to varchar having size more than 32K.
    Please help me to resolve this,
    Thanx in advance for the support,
    Nilesh

    Nilesh,
    . . . .The result of get_wkb() will not be human readable (all values are encoded into some binary format).
    SELECT utl_raw.cast_to_varchar2(tbl.geometry.get_wkt()) from FeatureTable tbl;
    -- resulting string:
        ☺AW(⌂özßHAA
    Å\(÷. . . .You may also want to have a look at { dbms_lob | http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm#i1015792 } "The DBMS_LOB package provides subprograms to operate on BLOBs, CLOBs, NCLOBs, BFILEs, and temporary LOBs."
    Regards,
    Noel

  • Inputing dates in non-US date format

    I know this is an old issue, but I could not find it resolved in the discussions and threads had been closed:
    I cannot figure out how to input dates using my preferred format mm/dd/yy (or dd.mm.yy, or even dd.mm.yyyy) despite having set it up that way in system preferences>international (using Irish, UK, or whatever settings).
    This occurs in Address Book where I try to input Birthdays (which I want included in iCal). It appears to want to make everything the current year and month (if dd>12 which makes it confused about dd or mm) or (if dd>=12) it assumes you are entering mm/dd/yy (contrary to my settings in System Preferences). The only way I have found around this problem is to write birthdays out in "long hand" (e.g. 31 May 1935)... Oddly if you give it something like 3/2/12 it will make it 2 March 2012 (rather than 3 February 1912 as intended). Which would be unlikely to say the least...
    Definitely not the kind of problem I would expect from MacOS!
    MacBook Mac OS X (10.4.7)
    MacBook   Mac OS X (10.4.6)  

    To customize the date (and any other format) to your particular preference, go to System Preferences; select International; select Formats. In the Dates section, select Customize. A pane will appear with Show:. From here you can select Short, Medium, Long or Full.
    As an example, I use Medium for my Mail using the dd mm yy format. To make this display, you simply move (rearrange) each of the elements of the day/month/format to your particular choice. You can insert any divider between each of these elements (I use a space).
    If you prefer the truncated Julian Date (yyD) format (for specific message/signals processing), simply delete the existing elements from the format line, and drag and drop a date element from the table below the element format line. For Julian Date, I selected Year and then Day of Year (without a space). I then modified the Year format by clicking on the Year element, which then displays a white chevron to right of the numeral. Click on the white chevron and several format options are available. Click your prefered option. Repeat the same process for Day of Year element.
    When you are satisfied, click OK.

  • How to convert internal date to the format of user default setting

    In the BDC program, I need to convert the date, such as the sy-datum 20070427, to the format of user default that is defined in T-code SU01, such as YYYY-MM-DD or YYYY.MM.DD, and so on.
    The user format has 6 six kinds, and it is not good idea to write the code to process. So I look for the functions or CLASS method to process. I can use the function 'ITS_GET_USER_DEFAULTS' to get the user default setting of the Date format and Decimal notation.The problem is that I can not find the function or CLASS method to convert the internal date to user's date format.
    The function: CONVERT_DATE_TO_INTERNAL can not do it.
    The CLASS method: cl_abap_datfm=>conv_date_int_to_ext may be do it. But I do know how exchange the parameters, and fail to make it work finely.
    Is there the functions or CLASS method to process it?
    Thanks a lot!

    Hi John,
    create a veriable :
    data: v_date type char10.
    then after getting the date in YYYYMMDD format, write the following statement.
    WRITE SY-DATUM TO V_DATE.
    this might solve your problem.
    Regards,
    Hemant.

  • JTextfield input Date convert to java.sql.Date

    Hi. I have a textfield for users to input date in 'dd/mm/yyyy' format and I would like to format this input into java.sql.Date to be stored into a database. How should I go about doing that ?
    I did the following:
    SimpleDateFormat formatDate = new SimpleDateFormat("dd/mm/yyyy");
    java.util.Date invoiceDate = formatDate.parse(jTextField3.getText());
    java.sql.Date sqlDate = new java.sql.Date(invoiceDate.getTime());and when I input into jTextField3 the value '28/05/2008' , I found in my database '2008-01-28'. January and May is a few months off and is totally not what I wanted.

    Hi you did you code perfect, but you need to change the pattern for formatting the Date
    dd - date
    mm - minute
    yyyy - year
    here you are parsing month as minute, so the output may wrong..!
    If you need to format properly
    please use the below pattern
    {color:#0000ff}SimpleDateFormat formatDate = new SimpleDateFormat("dd/MM/yyyy");{color}

  • Is there any function module to convert the date format

    Dear ABAPers,
    Is there any function module to convert the date format from dd.mm.yyyy to dd-mmm-yyyy.
           I want to convert the date format from dd.mm.yyy to dd.mmm.yyy Eg.from 10.03.2008 to 10-mar-2009.
    Thanks & Regards,
    Ashok.

    hi,
    create custom function module or copy the below code in the report ..and use it
    the out put for below is :----Convert a DATE field into a full format date eg. March 23, 2000
    FUNCTION Z_CONVERT_DATE_INTO_FULL_DATE.
    ""Local interface:
    *"       IMPORTING
    *"             VALUE(DATE) LIKE  SY-DATUM
    *"       EXPORTING
    *"             VALUE(FORMATTED_DATE)
    *"       EXCEPTIONS
    *"              INVALID_DATE
    TABLES: TTDTG.
    DATA: BEGIN OF T_DATE,
            YYYY(4) TYPE C,
            MM(2) TYPE C,
            DD(2) TYPE C,
          END OF T_DATE.
    DATA: DAY(3) TYPE N.
    DATA: VARNAME LIKE TTDTG-VARNAME.
    IF DATE IS INITIAL.
      CLEAR FORMATTED_DATE.
      EXIT.
    ENDIF.
    check document date format
    CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
      EXPORTING
        DATE = DATE
      EXCEPTIONS
        PLAUSIBILITY_CHECK_FAILED = 1.
    IF SY-SUBRC NE 0.
      RAISE INVALID_DATE.
    ENDIF.
    MOVE DATE TO T_DATE.
    CONCATENATE '%%SAPSCRIPT_MMM_' T_DATE-MM INTO VARNAME.
    SELECT SINGLE * FROM TTDTG WHERE SPRAS = 'EN' AND VARNAME = VARNAME.
    WRITE T_DATE-DD TO DAY.
    CONCATENATE DAY ',' INTO DAY.
    CONCATENATE TTDTG-VARVALUE DAY T_DATE-YYYY INTO FORMATTED_DATE
      SEPARATED BY SPACE.
    ENDFUNCTION.
    the output is :--Convert a DATE field into a full format date eg. March 23, 2000
    Regards,
    Prabhudas

  • Function module to convert calender date to Julian date format

    Hi,
    Is there any FM which can convert Calendaer Date to <b>Julian Date</b> format?
    Thanks.
    Regards,
    Madhu

    It is not a func mod... but it is pretty straight forward.
    data: julian_day(3) type n,
    date_aux type d,
    date_I_need type d.
    first day of the year
    concatenate date_I_need(4) '0101' into date_aux.
    julian_day = date_I_need - date_aux.
    julian_day = julian_day + 1.

Maybe you are looking for