Convert function?

hi
HOW TO CONVERT DATE TYPE TO TIMESTAMP TYPE? PLS GIVE EXAMPLE

Welcome to the Forum,
to convert data to timestamp
Example
SQL> SELECT TO_CHAR(sysdate,'MM/DD/YYYY HH24:MI:SS') "Date" FROM dual;
Date
09/29/2010 16:55:14
Convert DATE datatype to TIMESTAMP datatype
SQL> SELECT CAST(sysdate AS TIMESTAMP) "Date" FROM dual;
Date
29-SEP-10 04.55.14.000000 PM
see this link for more examples
http://www.databasejournal.com/features/oracle/article.php/2234501/A-Comparison-of-Oracles-DATE-and-TIMESTAMP-Datatypes.htm

Similar Messages

  • CONVERT function from SQL-Server 7.0 to Oracle

    Whenever a Convert function appears in the T-SQL, WorkBench converts it to RPAD and doesn't warm about it. How can I avoid this situation???
    It`s very urgent!! I`ve to migrate an entire system and I`m very short of time.
    Any comment would be helpfull!! Thanks!
    Julieta.

    THIS IS A DUPLICATE ENTRY AND REPLY, PLEASE USE ADD ADDITIONAL NOTES TO THE OTHER REPLY
    This has been logged as bug 1902143.
    Is altering the output from RPAD(12, 5, ' ') to RTRIM(RPAD(12, 5, ' ')) sufficient?
    Until this bug is fixed and released the only suggestion I can make is Generate Migration Scripts from the Action menu and then
    use an editor to alter the RPAD() to RTRIM(RPAD()).
    Turloch
    Oracle Migration Workbench Team

  • CONVERT function in SQL Server to oracle

    All,
    How to convert CONVERT function in SQL Server to oracle, below mentioned format is in SQL Server:
    variable1 = convert(numeric(20), SUBSTRING( parameter1,parameter2,parameter3)
    parameter1 datatype nvarchar2(100)
    parameter2 datatype bigint
    parameter3 datatype bigint
    I did bit R&D, but was not successful..but still getting on..
    If any help that would be great...
    Regards,
    ~ORA

    You cannot specify the precision/scale or length of input paramters to a stored procedure in Oracle, or at least the pl/sql engine does not respect the sizing. Assuming that you want to do something with variable1 in the procedure, and not just return it, the Oracle equivalent would be something along the lines of:
    SQL> CREATE FUNCTION f (p_param1 IN VARCHAR2,
      2                     p_param2 IN NUMBER,
      3                     p_param3 IN NUMBER) RETURN NUMBER IS
      4     l_var1 NUMBER(20) := SUBSTR(p_param1, p_param2, p_param3);
      5  BEGIN
      6     RETURN l_var1 * 10;
      7  END;
      8  /
    Function created.
    SQL> SELECT f('ABC10DEF', 4, 2) FROM dual;
    F('ABC10DEF',4,2)
                  100You may need to adjust the return type to match what you are actually returning.
    You can also use this iin a direct assignment in pl/sql without doig a select, something like:
    SQL> DECLARE
      2     l_num NUMBER(20);
      3  BEGIN
      4     l_num := f('ABC10DEF', 4, 2);
      5     DBMS_OUTPUT.Put_Line('The number is: '||l_num);
      6  END;
      7  /
    The number is: 100John

  • Error in convert function

    Hi
    I am using this query for retreiving the records from sql server.
    When the query
    select "e1" as emp,"e2" as date,"e3" as one_year rom "tablename"@databaselink
    it is working fine but when the same query is used with the convert function on one of the column like
    select "e1" as emp,convert(varchar,"e2",101) as date,"e3 as one from from "tablename"@databaselink
    it is saying ora-00936 error missing expression
    please help in this

    Hi,
    So, just to be clear - you are using a database link to connect from an Oracle database to a Microsoft SQL Server database?
    Have you been able to run basic SQL statements across the database link (i.e. just a plain 'SELECT * FROM')? Also, does this same SQL work okay when you run it directly against SQL Server (not through the DB Link from Oracle)?

  • Need inputs on CONVERT function in oracle.

    My source DB is : US7ASCII
    My target DB is : AL32UTF8
    Basically I am using oracle CONVERT funciton to convert the data.
    Unforutnately AL32UTF8 is not predefined in CONVERT function.
    So, is there are any other ways to convert the data ? Plz let me know.
    Thx,
    Vi.

    You have two databases. Database A uses a US7ASCII character set. Database B uses an AL32UTF8 character set.
    - Is all the data in Database A actually US7ASCII data?
    - What version of Oracle is Database A running? What version of Oracle is Database B running?
    - On which database are you running the CONVERT function?
    - Why do you believe you need to use the CONVERT function? If you are moving data from one database to another, Oracle should automatically take care of character set conversion.
    Justin

  • How to use "convert" function

    I work mm in my shop, but I need to convert to inches. I don't understand the instructions. Help!

    Hi Daru,
    I saw that in the instructions, no "mm" mentioned. But mm worked without the extra step of dividing... But there are so many glitches in this iWork version... it's really dumbed down.  But this was my problem, not the app. Thanks for your reply.
    It seems there are lots of things about the CONVERT function that could be more clearly documented.  Note here the 16 types of text that can be "prepended" to any metric unit:  of which "m" is just one (I got lucky).  For functions that Numbers and Excel have in common (in my experience Numbers has a pretty powerful subset of Excel functions, with the new Numbers adding some that the old Numbers didn't have) sometimes searching for descriptions of the Excel function yields more details.
    Thanks for the green tick.
    SG

  • Oracle CONVERT Function use in ODI

    Hi,
    I am using the convert function while doing data transfer between 2 databases in ODI.
    The NLS_CHARACTERSET of source data base is WE8ISO8859P1 and that of the target is AL32UTF8.
    When I use CONVERT(v_string, WE8ISO8859P1, AL32UTF8) as a target column expression in ODI Designer, it converts the pound symbols '£' in source data to '¿' in the target database. But for all other usual characters there is no such problem observed
    If anyone has faced such issue and resolved it or know any workaround, your help would be appreciated.
    Thanks.

    Don't pass the '£' character in the v_string and simply pre-pend it to the correctly converted string

  • Using convert function on nvarchar2

    Hi experts,
    I am having a bit of a problem with the convert function. We use convert to compare street- and citynames and ignore any special characters, such as é ç etc.
    Something like:
    select ...
    from   ...
    where  convert(new_street_name, 'US7ASCII') = convert(existing_street_name, 'US7ASCII')
    This works fine if the datatype is varchar2, for instance:
    SQL> select convert('äàáâçëèéêïìíîöòóôüùúûÿ','US7ASCII') text from dual;
    TEXT
    aaaaceeeeiiiioooouuuuy
    If the datatype if nvarchar2 however, the result is not as expected:
    SQL> select convert(cast('äàáâçëèéêïìíîöòóôüùúûÿ'as nvarchar2(64)),'US7ASCII') text from dual;
    TEXT
    慡慡捥敥敩楩楯潯潵畵
    The NLS character settings on our database (10.2.0.4) are:
    NLS_CHARACTERSET       AL32UTF8  Character set
    NLS_NCHAR_CONV_EXCP    FALSE     NLS conversion exception
    NLS_NCHAR_CHARACTERSET AL16UTF16 NCHAR Character set
    I have tried several combinations... but no luck so far. Is it possible to use convert on an nvarchar2 to go from é to e?
    Maybe it is better just to use the translate function and define each conversion explicitly. Convert seemed a nice option because it works without any additional parameters... on a varchar2 at least
    Thanks!

    The usage of convert is not encouraged by the docs and in my opinion it's rather by accident that this works in your specific case than something other.
    What's going on?
    Convert returns the char-datatype of the input.
    We can use simple to_char to use the convert funtion in the way you intend.
    (You shoud take care when handling n_char data in sql statements, especially in 10 g enviromnments. You have to set the environment parameter ORA_NCHAR_LITERAL_REPLACE=TRUE and use the n-prefix. Take a look at the globalization guide for more details.)
    CREATE TABLE  "TESTNCHAR"
       ( "ID" NUMBER,
    "STR" NVARCHAR2(30),
    "STR2" VARCHAR2(300)
    insert into testnchar values (1, n'ßäàáâçëèéêïìíîöòóôüùúûÿ','ßäàáâçëèéêïìíîöòóôüùúûÿ')
    select
    id
    ,str,str2
    ,dump(str,1010) dmp
    ,dump(str2,1010) dmp2
    ,dump(convert(str,'US7ASCII')) dc
    ,dump(convert(str2,'US7ASCII')) dc2
    ,convert(to_char(str),'US7ASCII') c
    ,convert(str2,'US7ASCII') c2
    from testnchar
    ID
    STR
    STR2
    DMP
    DMP2
    DC
    DC2
    C
    C2
    1
    ßäàáâçëèéêïìíîöòóôüùúûÿ
    ßäàáâçëèéêïìíîöòóôüùúûÿ
    Typ=1 Len=46 CharacterSet=AL16UTF16: 0,223,0,228,0,224,0,225,0,226,0,231,0,235,0,232,0,233,0,234,0,239,0,236,0,237,0,238,0,246,0,242,0,243,0,244,0,252,0,249,0,250,0,251,0,255
    Typ=1 Len=46 CharacterSet=AL32UTF8: 195,159,195,164,195,160,195,161,195,162,195,167,195,171,195,168,195,169,195,170,195,175,195,172,195,173,195,174,195,182,195,178,195,179,195,180,195,188,195,185,195,186,195,187,195,191
    Typ=1 Len=23: 63,97,97,97,97,99,101,101,101,101,105,105,105,105,111,111,111,111,117,117,117,117,121
    Typ=1 Len=23: 63,97,97,97,97,99,101,101,101,101,105,105,105,105,111,111,111,111,117,117,117,117,121
    ?aaaaceeeeiiiioooouuuuy
    ?aaaaceeeeiiiioooouuuuy
    We can see that this already fails for ß.
    To give you an idea of alternative approaches:
    create table test_comp (nid number, str1 varchar2(300), str2 varchar2(300))
    insert into test_comp values (1, 'ßäàáâçëèéêïìíîöòóôüùúûÿ','ssäàáâçëèéêïìíîöòóôüùúûÿ')
    insert into test_comp values (2, 'ßäàáâçëèéêïìíîöòóôüùúûÿ','säàáâçëèéêïìíîöòóôüùúûÿ')
    select
    from test_comp
    where
    str2 like str1
    no data found
    select
    from test_comp
    where
    upper(str2) like NLS_UPPER(str1, 'NLS_SORT = XGERMAN')
    NID
    STR1
    STR2
    1
    ßäàáâçëèéêïìíîöòóôüùúûÿ
    ssäàáâçëèéêïìíîöòóôüùúûÿ

  • Oracle convert function

    Friends and Gurus,
    Table: comments
    column: c1
    characterset: WE8IS08859P1
    I am trying to use Oracle convert function to identify rowid's where column length greater than 4000 characters.
    Table comments was created under 'WE8IS08859P1' characterset and I'm moving this table to 'AL32UTF8'.
    I don't have csscan installed so trying to query sql and convert column to 'AL32UTF8' characteset and find rowid's to fix.
    I have tried below but doesn't help
    SELECT MAX(length(CONVERT(c1,'AL32UTF8'))) FROM comments;
    SELECT length(CONVERT(c1,'AL32UTF8'))
    FROM comments
    WHERE length(c1) > 4000;
    did anybody faced similar issue?

    Hi,
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved, so that the people who want to help you can re-create the problem and test their ideas.
    Simplify the problem as much as possible.  For example, instead of looking fro strings that have more than 4000 characters (or bytes), post a problem where you want to find strings longer than 4 characters (or bytes).
    Always say which version of Oracle you're using (for example, 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002
    Are you interested in the number of characters, or the number of bytes?  Use LENGTHB if you want the length in bytes.

  • Want to convert function in SQL Server 2000

    Hi ,
    i am writing this function in oracle.Could you please convert this function in SQL Server 2000 because i am new in this and dont know how to use decode function in sql.
    Please following is the code for oracle.
    CREATE OR REPLACE function fun ( localex varchar2,titlex varchar2)
    return number
    as  x number;
    begin
    select sum ( decode (count (username),max(prereq_count),1,0) ) x into x from
       SELECT
                       prereq_count,
                       username
                 FROM
                         table1
    group by     username ;
    return x;
    end fun;
    Regards
    Vishal

    Just take a look example below might give you idea :
    create or replace function f_makeAddress_tx (
    i_address_tx VARCHAR2,
    i_city_tx VARCHAR2,
    i_state_tx VARCHAR2,
    i_zip_tx VARCHAR2)
    return VARCHAR2
    is
    e_badZip EXCEPTION; u279E8
    pragma EXCEPTION_init(e_badZip,-20998); u279E9
    v_out_tx VARCHAR2(256);
    begin
    p_validateZip (i_zip_tx); u279E12
    v_out_tx:= i_address_tx||u2019, u2018|| u279E13
    i_city_tx ||u2019, u2018||
    i_state_tx ||u2019, u2018||
    i_zip_tx;
    return v_out_tx; u279E17
    exception
    when e_badZip then u279E19
    return i_zip_tx || u2018: Invalid zip code.u2019;
    end;
    Regards,
    Clint

  • Problem with SQL Convert Function Junk Character

    Hi All,
    We have a database field that has a value of “2.020 OPERATOE’S CAB – GLASSES” on the front end of Oracle E-Business Suite. When we are spooling that column(in PLSQL) with the SQL covert function , one of the characters(’) in the string is not getting converted properly. It is displayed as a junk character in the spooled file.
    We used CONVERT(p_column,'WE8ISO8859P1','UTF8') for converting the string and utl_file api for spooling the output file. Please note that converted string is passed to utl_file.fopen directly.
    Following are the nls_parameters values.
    NLS_CHARACTERSET ~~ UTF8
    NLS_NCHAR_CHARACTERSET ~~ AL16UTF16
    Any inputs are welcome.
    Thanks
    gt1942

    Hello All,
    Sorry, If I am opening the blog in the wrong place as this is the first time.
    my out looks as follows.
    "02920  "
    but when i see in the application there is nuthing in the end.
    so I used regexp_replace(p_vendor_dtl,'[^[!-~]]*',''), But this is removing spaces also. I don't want to remove space. I want to remove this character only.
    Please help
    Thanks.

  • FM to convert functional location to internal format

    Hi all,
    Is there any fucntional location that converts a funcitonal location to internal format?
    Eg: Input to FM is : METER7
    Output from FM should be : ?0100000000000000759
    Please let me know.
    Thanks & Regards,
    Srilakshmi B

    Try following code.
    CALL FUNCTION 'CONVERSION_EXIT_TPLNR_INPUT'
        EXPORTING
          INPUT                      = l_floc
      I_FLG_CHECK_INTERNAL       = 'X'
       IMPORTING
          OUTPUT                     = l_floc_int
    EXCEPTIONS
      NOT_FOUND                  = 1
      OTHERS                     = 2.
    Hope it helps..
    johnson zavier

  • Date convertion function in BPS layout

    Hi,
       At the user's request, I have created a key figure with date type "date". The purpose of this is to allowed the user can input the date for each of the material displayed at the BPS layout.
       when I use the listcube to display the date key figure, I notice that it is not display as the regular date instead it has benn converted to a number for example 01/12/2005 is dispaly as 731,959. when I delete the date from the layout and save it,now the cube has add a 731,959- record. this is comply with how the infocube deal with ket figure data.
       There should be an function which convert the date 01/10/2005 to 731.595 in the BPS back end, anybody know the function name.
    Thanks,

    Hi JW,
    If you simply want to generate a new date from an existing one, there are several options using only FOX. But again, maybe you want to look at the original intention of the application and your data modelling options before researching into this specific issue.
    William

  • Number to Word Convert Function

    Dear All,
    Plz anybody have function name which can convert NUMBER to WORD.
    example:  1213 to One Thousand Two Hundred Thirteen
    thanks,
    RP

    rp,
      Pls. use below FM...
    CALL FUNCTION 'SPELL_AMOUNT'
    EXPORTING
    AMOUNT = amouno
    CURRENCY = 'USD'
    FILLER = ' '
    LANGUAGE = SY-LANGU
    IMPORTING
    IN_WORDS = SPELL
    EXCEPTIONS
    NOT_FOUND = 1
    TOO_LARGE = 2
    OTHERS = 3.
    Check
    http://www.sap-img.com/fu001.htm
    (OR)
    Also you can use FM HR_IN_CHG_INR_WRDS.
    report ztest02.
    data: words(50) type c.
    call function 'HR_IN_CHG_INR_WRDS'
    exporting
    amt_in_num = '100000'
    importing
    amt_in_words = words.
    write:/ words.
    Pls. Reward if useful

  • UpperCase Convert Function

    Can anybody tell me how to write a function to convert inputtextbox data information to uppercase before save to the oracle 10g database?
    My working environment is JSF, ADF BC.
    I am new to jdeveloper and this is my first project. I am not able to find document related to writing function to uppercase.
    I greatly appreciate your help in this matter.

    Go to the set method for your item in your entity object xxximpl.java file. (for example the setEname).
    And in the first row of that item write something like data=data.toUpperCase();
    You are using a Java built in method for a String variable to do this before it gets sent to the DB.

  • Date convert Function module

    Hello,
    Is there any function module thru which i can convert SY-DATUM to DD-MMM-YYYY (13-Apr-2007) format.
    Appreciate any quick replies.
    Message was edited by:
            Salahuddin Syed

    HI,
    Welcome to SDN!!!!!!!
    Check this..
    <b>
    DATA: V_INPUT(8) VALUE '20112006'.
    DATA: V_CHAR(25).
    data: date type sydatum.
    DATA: MONTH_NAMES LIKE T247.
    SELECT SINGLE * FROM T247
    INTO MONTH_NAMES
    WHERE SPRAS = SY-LANGU
    AND MNR = V_INPUT+2(2).
    CONCATENATE MONTH_NAMES-KTX V_INPUT(2) V_INPUT+4(4)
    INTO V_CHAR SEPARATED BY SPACE.
    write: / V_CHAR.</b>
    or
    Please check this FM HR_IN_GET_DATE_COMPONENTS.
    <b>DATA: L_DAY(2)   TYPE C,
          L_MONTH(2) TYPE C,
          L_YEAR(4)  TYPE C,
          L_LTEXT    TYPE T247-LTX.
    DATA: L_DATE TYPE STRING.
    CALL FUNCTION 'HR_IN_GET_DATE_COMPONENTS'
      EXPORTING
        IDATE                         = SY-DATUM
      IMPORTING
        DAY                           = L_DAY
        MONTH                         = L_MONTH
        YEAR                          = L_YEAR
        LTEXT                         = L_LTEXT
      EXCEPTIONS
        INPUT_DATE_IS_INITIAL         = 1
        TEXT_FOR_MONTH_NOT_MAINTAINED = 2
        OTHERS                        = 3.
    CONCATENATE L_LTEXT ',' INTO L_DATE.
    CONCATENATE L_DATE L_DAY L_YEAR INTO L_DATE SEPARATED BY SPACE.
    WRITE: L_DATE.</b>
    Regards
    SAB

Maybe you are looking for

  • Forgot Password Only have install disks for 10.4 and disk #2 for 10.5

    Hello, I was playing around on my macbook last night and changed my password to a password that i always use for just about everything and when i changed it worked because i had to logout cause something froze and safari was really messed up so when

  • Route pattern to SIP trunk problem

    Hello, I have a 2801 router that has been configured with CME and a working SIP connection to my local ISP. Tested with calls via CME so I know for sure that the SIP config and dial plan is fine on this gateway. Next I wanted to try out CUCM so I set

  • How do i fix error 9 on my ipod touch

    ok so my ipod went dead for a few days so i went to charge it and i got the symbol on the screen to connect it to itunes. i connected it and it said that i had to restore my ipod...so i clicked restore...it was almost finished restoring and it came u

  • Junk Mail from a specific individual making me insane....how can I block it

    I'm getting junk mail from a friend of a friend, and I mark his messages as junk EVERY TIME I GET ONE. Yet, somehow, alas, every message from him gets through to my inbox. How can this (and a homicide) be prevented? If you mark a message "Junk" why i

  • AK Loader file Upload Error

    Hi, I am facing problem at the time of patching on 11.5.10 system. ==========AD Worker ERROR================= Calling /u2/oracle/prodcomn/util/java/1.4/j2sdk1.4.2_04/bin/java ... Start of Core Modules - AK Loader file Upload Session. TUE 01 08 2013 1