How to convert varchar to timestamp

in the db , i have a column indtalledDate with datatype varchar-- and value is like 'Thu Dec 20 07:33:20 PST 2012'. Now i need to convert this to timestamp format-->20-DEC-12 07.47.49.463000000 AM . how can i do?
can anyone pls help???

>
hi..Thanks for the quick reply. yes it worked. Now i do need to determine the day in month, quarter span, month span,year start date and year end date..
something like below:
to_date(add_months(trunc(installeddate,'q'),3)-1) - to_date(trunc(installeddate,'q')) as quarter_time_span
any idea how to do this?
You already have an idea of how to do that
select trunc(sysdate, 'yyyy') year_start,
   add_months(trunc(sysdate, 'yyyy'), 12) next_year_start,
   trunc(sysdate, 'q') quarter_start,
   add_months(trunc(sysdate, 'q'), 3) next_quarter_start,
   to_number(to_char(sysdate, 'dd')) day_in_month,
   trunc(sysdate, 'mm') month_start,
   add_months(trunc(sysdate, 'mm'), 1) next_month_start from dual
YEAR_START,NEXT_YEAR_START,QUARTER_START,NEXT_QUARTER_START,DAY_IN_MONTH,MONTH_START,NEXT_MONTH_START
1/1/2012,1/1/2013,10/1/2012,1/1/2013,20,12/1/2012,1/1/2013

Similar Messages

  • How to convert DATE to TIMESTAMP

    Hi People,
    I need to know how to convert a date attribute to a timestamp.
    I am using Oracle 11g database, SQL Dev 3.
    I am selecting a date field in my query and I want to convert this field to a timestamp.
    How should I do this ?
    select
             x.created_time,
    from order_tbl xThanks for the help !

    Hi,
    CAST is great for that:
    SELECT     CAST (created_time AS TIMESTAMP)     AS created_timestamp
    FROM     order_tbl; 
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.

  • How to convert varchar to int in MSSQL?

    Hi,
    I am using mssql. how can i convert varchar to int type.
    for eg.
    id (int) txt(varchar)
    1 ---------10
    2 ---------10a
    3 ---------10b
    i want to convert varchar to int. HOw? pls explain with query.
    Thanks
    edward

    "10a" wouldn't normally be considered a number. So what sort of number do you expect it to be?
    Other than that you can look at the substring and convert/cast functions.

  • How to convert varchar to date datatype while insert or update in table

    Hai All
    I need to convert to varchar to date.
    I have two Tables T1,T2
    T1 Structure
    Code varchar
    Time varchar
    Date varchar
    T2 Structure
    Empname var
    Empcode var
    Intime date
    Outtime date
    Intrin date
    Introut date
    Att_date
    Now i need to move Time form T1 to T2 Intime,outtime,intrin,introut according some condition
    So now i need to convert Varchar to Date while insert or update
    I have tried something
    Insert into T1 (code,intime,att_date)values
    (code,To_date(Date||time,'dd-mon-yyyy hh24mi'),att_date);
    OR While update
    Update T2 set Outtime=To_date(Date||time,'dd-mon-yyyy hh24mi') where...
    I got an error Ora-01861
    Regards
    Srikkanth.M

    You didn't show any example of your date or time values, butyou might need to add a space between them, like
    To_date(Date || ' ' || time,'dd-mon-yyyy hh24mi')

  • Problem in converting varchar to timestamp

    Hi all,
    I'm having one varchar column which has data like,
    2008-08-01T12:00:16.000000+00:00
    i need to extract '2008-08-01 12:00:16' and put into an timestamp solumn.
    How can this be done.
    i tried the below query,
    SELECT to_date((to_date((SUBSTR((REPLACE(TI,'T',' ')),1,20)),'YYYY-MM-DD HH24:MI:SS')),'YYYY-MM-DD HH24:MI:SS') FROM TI;
    which is giving only '08-AUG-01'
    How can i do this? Please help me in resolving this.
    Thanks in advance,
    Karthick

    What? Why would you lose your time?
    You are only losing it in your display because you are not specifying it correctly to display. Internally the date datatype always has a time though it defautls to 00:00:00 if you do not provide time information on the initial to_date.
    Is the target table or variable data type a date or a timestamp (pontentially with time zone)?
    Just format the character string into the expected time stamp format and use to_timestamp on it if the target is a timestamp.
    From the SQL manual 10gR2
    SELECT TO_TIMESTAMP ('10-Sep-02 14:10:10.123000', 'DD-Mon-RR HH24:MI:SS.FF')
       FROM DUAL;
    TO_TIMESTAMP('10-SEP-0214:10:10.123000','DD-MON-RRHH24:MI:SS.FF')
    10-SEP-02 02.10.10.123000000 PMHTH -- Mark D Powell --

  • Convert varchar to timestamp(3)

    Hello folks,
    Can anyone help me in converting a varchar2(200) into a timestamp(3).
    I want it in this format '07-DEC-06 12.00.00.000000000 AM'
    Thanks in advance.

    SQL> select to_timestamp('Oct 21 2009 12:59PM', 'Mon DD YYYY HH12:MIAM', 'NLS_DATE_LANGUAGE = ENGLISH') from dual;
    TO_TIMESTAMP('OCT21200912:59PM
    21/10/09 12:59:00,000000000Again, as Centinul said, remember that it's an internal representation that has nothing to do with how it's being displayed on your screen
    Edited by: fsitja on Dec 22, 2009 12:53 AM
    edit for an NLS independent solution

  • How to convert varchar to BLOB in oracle 10g?

    Hi all,
    I have 2 columns A and B which are of varchar2(2000) dataype.
    I would like to concatinate these 2 columns and convert them into BLOB in oracle 10g.
    Any help is appreciated.
    Regards,
    Ravi

    don't use BLOB to store large text, use CLOB instead
    anyway:
    SQL> create table test
      2  (txt varchar2(10)
      3  ,other varchar2(10)
      4  );
    Table created.
    SQL>
    SQL> insert into test values ('some text', 'other text');
    1 row created.
    SQL>
    SQL> create table test2
      2  (col blob)
      3  /
    Table created.
    SQL>
    SQL> insert into test2
      2  select utl_raw.cast_to_raw (txt||other)
      3    from test
      4  /
    1 row created.
    SQL> select *
      2    from test2
      3  /
    SP2-0678: Column or attribute type can not be displayed by SQL*Plus
    SQL>
    SQL> select utl_raw.cast_to_varchar2(col)
      2    from test2
      3  /
    UTL_RAW.CAST_TO_VARCHAR2(COL)
    some textother text
    SQL>
    SQL> drop table test
      2  /
    Table dropped.
    SQL> drop table test2
      2  /
    Table dropped.

  • How to convert VARCHAR to SMALLINT using DB2?

    Hi, guys:
    I am trying to do some comparison in my sql code:
    A.mySmallInt = B.mySmallIntAsString
    Unfortunately, mySmallInt is stored as 1, 2, 3, ..... while
    mySmallIntAsString is stored as '1', '2', '3'......
    I am wondering if there is a DB2 function that can directly
    convert a string into an interger or vice versa?
    thanks a lot

    I believe you can use CAST(B.mySmallIntAsString AS DECIMAL).
    Hi, guys:
    I am trying to do some comparison in my sql code:
    A.mySmallInt = B.mySmallIntAsString
    Unfortunately, mySmallInt is stored as 1, 2, 3, .....
    while
    mySmallIntAsString is stored as '1', '2', '3'......
    I am wondering if there is a DB2 function that can
    directly
    convert a string into an interger or vice versa?
    thanks a lot

  • How to convert varchar to date?

    Hello everyone, I'm new to OBIEE and I'm running into a roadblock...
    I have a date that is stored in a varchar2 column in the physical table, like so: 20071225
    Silly I know, but that's what I'm dealing with.
    Anyway, I want to create a logical column in the business model (using the Administration tool) and convert it to a date so that I can do date arithmetic with it, but TO_DATE doesn't seem to be supported.
    In Oracle SQL would do this (I'm using XE):
    SELECT SYSDATE - TO_DATE('20050101', 'YYYYMMDD') FROM DUAL
    Is there any way to accomplish this same thing in the OBIEE? I see the CAST function, but there doesn't seem to be any way to cast a string to a date?

    The original post is 4 years old - I am sure the poster must have figured it out by this time... obiee 11g supports a To_Datetime function though! thanks!

  • How to Convert Date Object at Universe Level with out Timestamp

    Hi,
    I have a Object  called "PCREGISTERDATE" at universe where the data type is date .but the dates are coming in the following format:9/26/2007 9:48:40 PM but i want to show the date as with out time stamp.
    how can i create a object by at universelevel which shoul show only date with out Time Stamp.
    please help me on this ASAP.
    Thanks & Regards,
    Kumar

    Please try below date fucntion:
    select convert(varchar(10),getdate(),101)  - this is for sybase
    syntex will change based on your source database.
    Thanks
    Ponnarasu .K

  • How to convert date in varchar format to TimeZone format?

    Hi,
    Iam having a date '14-05-08 09:46:35 AM' (in Varchar format). How to convert this date to TimeZone ('IYYY-MM-DD"T"HH12:MI:SS"Z"FX') format?
    For Example,
    My input date is '14-05-08 09:46:35 AM' and I need output as '2008-05-14T09:46:35Z'.
    How to convert this?
    Thanks in Advance.

    Hi,
    You would look up the TO_TIMESTAMP and the TO_CHAR functions in the SQL reference manual for the version you don't mention, and make up the solution yourself, rather than asking someone else to do your homework.
    Sybrand Bakker
    Senior Oracle DBA

  • How to convert oracle timestamp to java timestamp

    Hi,
    I need to convert oracle timestamp that i got from oracle database to java timestamp.I tried to use getTimestamp() to get timestamp value from oracle, but am getting NumberFormatException.
    Could any of suggest how to convert oracle timestamp to java timestamp.

    Thanks jverd ,
    then my code will be like:
    String oracleTS="11-MAR-05 11.19.20.625 AM";
    // am looking for yyyy-MM-dd HH:mm:ss format
    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd
    HH:mm:ss");           
    Timestamp javaTimestamp=Timestamp.valueOf(oracleTS);
    System.out.println("javaTimestamp----->>
    "+javaTimestamp);
    ving java.lang.NumberFormatException: For input
    string: "MAR"Well, the SimpleDateFormat has to actually match the format you're trying to parse, for one thing. Then you have to actually USE the SDF, which you didn't.
    You really haven't made it clear what you're trying to do, and it doesn't appear that you bothered to study the links I provided.
    DateFormat df = new SimpleDateFormat("dd-MMM-yy HH.mm.ss.SSS aa");
    Date date = df.parse(oracleTS);
    Timestamp ts = new Timestamp(date.getTime());

  • How to convert epoch time stamp to timestamp.

    Hi,
    I need a help regarding how to convert the epoch Time stamp, to oracle date and time format.
    for example,
    for epoch time stamp:1204104116656
    the time stamp should be :2008-02-13 12:43:00.351
    Please help me on the same

    SQL> select timestamp '1970-01-01 00:00:00' + numtodsinterval(1204104116656/1000,'second') from dual;
    TIMESTAMP'1970-01-0100:00:00'+NUMTODSINTERVAL(1204104116656/1000,'SECOND')
    27-FEB-08 09.21.56.656000000 AM
    SQL> select (timestamp '1970-01-01 00:00:00' + numtodsinterval(1204104116656/1000,'second')) at time zone tz_offset('EST') from dual;
    (TIMESTAMP'1970-01-0100:00:00'+NUMTODSINTERVAL(1204104116656/1000,'SECOND')
    27-FEB-08 08.21.56.656000000 AM -05:00
    SQL> select (timestamp '1970-01-01 00:00:00' + numtodsinterval(1204104116656/1000,'second')) at time zone tz_offset('PST') from dual;
    (TIMESTAMP'1970-01-0100:00:00'+NUMTODSINTERVAL(1204104116656/1000,'SECOND')
    27-FEB-08 06.21.56.656000000 AM -07:00
    SQL> select (timestamp '1970-01-01 00:00:00' + numtodsinterval(1204104116656/1000,'second')) at time zone tz_offset('Europe/Berlin') from dual;
    (TIMESTAMP'1970-01-0100:00:00'+NUMTODSINTERVAL(1204104116656/1000,'SECOND')
    27-FEB-08 03.21.56.656000000 PM +02:00
    SQL> select (timestamp '1970-01-01 00:00:00' + numtodsinterval(1204104116656/1000,'second')) at time zone tz_offset('Canada/Mountain') from dual;
    (TIMESTAMP'1970-01-0100:00:00'+NUMTODSINTERVAL(1204104116656/1000,'SECOND')
    27-FEB-08 07.21.56.656000000 AM -06:00SY.

  • How to convert  Timestamp  into exact Date and Time(FM)

    Hi Gurus,
    could anyone tel me  ,
    e.g:20.11.2008:11:23:54am
    How to convert Time stamp  into exact Date and Time

    Hi,
    Following is one way of doing it
    Timestamp timeStamp = new Timestamp(Calendar.getInstance().getTimeInMillis());
              System.out.println(timeStamp);
              SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
              System.out.println(dateFormat.format(timeStamp));
              SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
              System.out.println(timeFormat.format(timeStamp));
    Output
    2008-11-20 11:59:35.693 -> Timestamp
    11/20/2008
    11:59:35
    Regards
    Ayyapparaj

  • How to convert  from  varchar to blob ?

    How to convert from varchar to blob ?
    thanks

    Here is a small PL/SQL block that we have used to convert varchar2 to blob.
    declare
    cursor get_blob is
    select blob_statement
    from report
    where report_id = 205
    FOR UPDATE OF blob_statement;
    v_loc blob;
    v_raw_buffer raw(32767);
    v_amount binary_integer := 32767;
    v_offset binary_integer := 1;
    v_buffer VARCHAR2(32767);
    begin
    open get_blob;
    fetch get_blob into v_loc;
    close get_blob;
    v_buffer := 'Sample text';
    v_raw_buffer := utl_raw.cast_to_raw(v_buffer);
    v_amount := utl_raw.length(v_raw_buffer);
    dbms_lob.write(v_loc, v_amount, v_offset, v_raw_buffer);
    commit;
    end;

Maybe you are looking for

  • How do I add a background color to a document in Pages?

    How do I add a background color to a document in Pages?  I have made an invitation, with a photo in it, the text is in color, and I want to make the background pink instead of white.  thanks

  • Gos attachment knowlenge provider:  transfer error ?

    hi friends ı wrote this code but ı take this error 'Knowlenge provider : transfer error'. please help me ? thanks. DATA: o_document_set TYPE REF TO cl_bds_document_set,   wa_signature LIKE bapisignat,   i_signature LIKE bapisignat OCCURS 1,   wa_file

  • Equipment Download from ECC 6.0 to CRM 5.0

    Hi, I have made equipment in ECC 6.0 using the Transaction code IE01. While trying to download it into CRM, the BDoc shows a validation error I have activated the adapter objects EQUI_CONFIG and EQUIPMENT. I will be obliged If somebody can give me th

  • BGB Best path selection

    Hi, Could someone tell me why second path remains as best? MPLS_CORE#show ip bgp 192.168.1.0 BGP routing table entry for 192.168.1.0/24, version 27 Paths: (2 available, best #2, table default)   Advertised to update-groups:      1            Refresh

  • Will FCS 5.1 install OK on OS10.6?

    Hi, Has anyone else tried this? I inserted FCS disc one (with main program on) and it said I need to install Rosetta first?? Surely this is not necessary because the software was fine on an Intel iMac dual core before?? I recall Rosetta was only requ