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 --

Similar Messages

  • 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

  • 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

  • Convert from epoch timestamp to human readable date

    Hi everybody,
         I want to retrieve a human readable date from an fpga target of a sbRIO9636 ,so what is the function which can convert an epoch timestamp to a human readable date ? 
    (Noting that i need to retrieve the second,minute,hour,day,month,year... from the fpga target of this device)
    Thanks

    I have a program which retrieve the current time of windows (with the Get Date/Time in Seconds and Seconds to Date/time functions) and calculate the julian day parameter by using the second,minute,hour,day,month and year wich are displayed on the elements of the Unbundle By Name function (connected in the output of Seconds to Date/time function).
    This program works within windows and real time but I can't run it in the chassis of the sbRIO (errors displayed that these functions above aren't supported in the current target)
    Can i use another method to solve this problem.
    (See the front panel of this program in the following attached file)
    Attachments:
    julian day.PNG ‏110 KB

  • Convert varchar to decimal - arithmetic overflow

    I'm using SQL Server 2014 and I'm trying to convert data from a staging table over to a production table. I seem to be getting an Arithmetic overflow error converting varchar to numeric on the decimal conversion. I'm sure I've overlooked something with the
    syntax of the CONVERT.
    This is the staging table:
    CREATE TABLE [dbo].[staging_table](
    [TimeIndex] [varchar](100) NULL,
    [Cluster] [varchar](100) NULL,
    [AvgMem] [varchar](100) NULL,
    [AvgCPU] [varchar](100) NULL,
    [TotalMemory] [varchar](100) NULL,
    [TotalCPU] [varchar](100) NULL,
    [Datacenter] [varchar](100) NULL,
    [vCenter] [varchar](100) NULL
    ) ON [PRIMARY]
    This is the prod table I'm moving it to:
    CREATE TABLE [dbo].[Clusters](
    [ClusterID] [int] IDENTITY(1,1) NOT NULL,
    [ClusterName] [varchar](25) NULL,
    [DatacenterName] [varchar](25) NULL,
    [TimeIndex] [datetime] NULL,
    [AvgCPU] [decimal](5, 2) NULL,
    [AvgMem] [decimal](5, 2) NULL,
    [TotalCPU] [decimal](8, 2) NULL,
    [TotalMem] [decimal](8, 2) NULL,
    [vCenterID] [int] NULL,
    CONSTRAINT [PK_Clusters_1] PRIMARY KEY CLUSTERED
    [ClusterID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    and here's an example INSERT INTO statement throwing the error:
    INSERT INTO [dbo].[Clusters] (ClusterName,DatacenterName,TimeIndex,AvgCPU,AvgMem,TotalCPU,TotalMem,vCenterID)
    SELECT SUBSTRING(Cluster,1,25) AS ClusterName,
    SUBSTRING(Datacenter,1,25) AS DatacenterName,
    CONVERT(datetime,TimeIndex,103) AS TimeIndex,
    CONVERT(decimal(5,2),AvgCPU) AS AvgCPU,
    CONVERT(decimal(5,2),AvgMem) AS AvgMem,
    CONVERT(decimal(8,2),TotalCPU) AS TotalCPU,
    CONVERT(decimal(8,2),TotalMemory) AS TotalMem,
    '3' FROM [dbo].[staging_table]
    Sample data is 0.00 to 100.00 in fields AvgCPU and AvgMem, and TotalCPU and TotalMem usually goes up to about 7 digits with no decimal (eg. 7543253) but could be 8 and although I've never seen a decimal I wouldn't rule it out so decided to account for it.
    I assume it's something I've overlooked with the syntax but any ideas would help.
    Thanks
    Adam

    The problem is your precision and scale you are assigning to your decimals.
    decimal(5,2) = this is a total of 5 digits, 3 digits for the whole number and 2 for the fractional.
    decimal(8,2) = this is a total of 8 digits, 6 digits for the whole number and 2 for the fractional. 
    So converting a varchar of 7 or 8 digits for TotalCPU or TotalMem will give you an error because your definition will actually only allow for 6 digits of storage. You could test this by doing decimal(8,0) or decimal(10,2) both which will allow for up to
    8 whole numbers.
    If you are worried about space Sql Server will allocate a set number of bytes for ranges based on the precision (first number in the parenthesis). See this page which explains in detail how much space each range takes up and also further details on
    decimal and numerics.
    -Igor

  • Convert Varchar to Date

    Hi
    im trying to convert varchar to date.
    So, i used To_date ( cilumn, 'DD-MM-YYYY') , Since i have to order the out put in Decending Order i used the same convertion function with Order by clause.
    The problem is ... the out put is not ordered,
    <sql>
    select date_created
    from
    select distinct
    to_date(created_date,'DD-MM-YYYY') as date_created
    from schedule_backup
    order by date_created desc
    <sql>
    out put is
    =================
    DATE_CREA
    26-NOV-09
    23-NOV-09
    19-NOV-09
    16-NOV-09
    11-NOV-09
    04-NOV-09
    30-OCT-09
    11-SEP-09
    04-MAR-10
    01-MAR-10
    25-FEB-10
    DATE_CREA
    22-FEB-10
    17-FEB-10
    15-FEB-10
    11-FEB-10
    09-FEB-10
    03-FEB-10
    27-JAN-10
    20-JAN-10
    15-JAN-10
    04-JAN-10
    thanks
    raj

    Hi, Raj,
    When you store dates in a VARCHAR2 column, you're asking for touble, so it seems that everything is working according to plan.
    Even aside from that, your query works perfectly for me.
    In the output you posted, the order is correct within each year, and you're only showing 2 digits of the year. Are you sure the centuries are right in the schedule_backup table? Perhaps everything that was supposed to be '2010' got enetereed as '1910' or '0010'.
    Post some sample data (CREATE TABLE and INSERT statements) that gets the wrong results with your query.
    For example:
    CREATE TABLE     schedule_backup
    (     created_date     VARCHAR2 (10)
    INSERT INTO schedule_backup (created_date) VALUES ('11-11-2009');
    INSERT INTO schedule_backup (created_date) VALUES ('04-11-2009');
    INSERT INTO schedule_backup (created_date) VALUES ('30-10-2009');
    INSERT INTO schedule_backup (created_date) VALUES ('11-09-2009');
    INSERT INTO schedule_backup (created_date) VALUES ('04-03-2010');
    COMMIT;

  • Problem in converting Spool Request into PDF format

    Hi,
      I am facing problem to convert spool request (which store output of sap script) in to PDF format. Actually I have converted it with function module 'CONVERT_OTFSPOOLJOB_2_PDF' and it is working properly but the problem occurs where the BOLD fonts are used. I am unable to see the Text/Address where i have used Bold Font in script (PDF FORMAT). Even though in (SPO1) spool request shows every thing perfectly (along with Bold Font). It will great if you could suggest me something.
    Thanks,
    Pradeep

    Hi Pradeep,
    Use ,
    Closing the Sapscript, we save data (OTF) in a table
    CALL FUNCTION 'CLOSE_FORM'
    TABLES
    otfdata = t_otfdata
    EXCEPTIONS
    unopened = 1
    bad_pageformat_for_print = 2
    send_error = 3
    spool_error = 4
    OTHERS = 5.
    DATA: BEGIN OF t_otfdata2 OCCURS 0.
    INCLUDE STRUCTURE solisti1.
    DATA: END OF t_otfdata2.
    Move OTF data to another table with lenght 255
    LOOP AT t_otfdata.
    CONCATENATE t_otfdata-tdprintcom t_otfdata-tdprintpar INTO t_otfdata2.
    APPEND t_otfdata2.
    ENDLOOP.
    Convert OTF format to PDF
    CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
    EXPORTING
    format_src = 'OTF'
    format_dst = 'PDF'
    devtype = 'PRINTER'
    FUNCPARA =
    len_in = len_in
    IMPORTING
    len_out = len_out
    TABLES
    content_in = t_otfdata2
    content_out = t_pdfdata
    EXCEPTIONS
    err_conv_failed = 1
    OTHERS = 2.
    Have a look at Progs. RSTXPDF4 and RSTXPDFT2 for converting the Spool to PDF.
    Regards,
    Raj
    Message was edited by: Rajasekhar Dinavahi
    Message was edited by: Rajasekhar Dinavahi

  • Problem in converting Spool to PDF file, having non-English characters

    Hi All,
            I have problem in converting Spool to PDF format.
    Scenario : I have a spool which has non-English characters. I am using CONVERT_ABAPSPOOLJOB_2_PDF  FM to perform conversion. But my output is having junk values( ie # ) for non-English characters. Any pointers to solve this issue will be appreciated.
    I even tried with report RSTXPDFT4 , it also gives me the same junk characters.
    Regards,
    Navin.

    Hi All,
            I have problem in converting Spool to PDF format.
    Scenario : I have a spool which has non-English characters. I am using CONVERT_ABAPSPOOLJOB_2_PDF  FM to perform conversion. But my output is having junk values( ie # ) for non-English characters. Any pointers to solve this issue will be appreciated.
    I even tried with report RSTXPDFT4 , it also gives me the same junk characters.
    Regards,
    Navin.

  • Hyperlink problem when converting Word to PDF

    Hi everyone.
    I am using Adobe Acrobat 7.0 Standard version 7.1.4 on a Windows 2000 environment.
    I am using Word XP/2002 SP3.
    I have a couple of problems when converting Word to PDF.
    When converting a long link which is in 2 lines, PDF just takes one line into account, not considering the whole link
    When I have hyperlinks that links to a web page, the link works fine in Word but in pdf, it gets the few words after the url address making the link not work.  For example.  I have a hyperlink that http://www.google.com/ and after this I have the words: "This is a sample text".  The hyperlink in pdf would then become http://www.google.comThisisasampletext
    Do you have any ideas how I can correct this?
    Thanks.

    To get the cross references, you have to use Convert to PDF (PDF Maker part of the Acrobat product). However, you first need to go to the print menu and set the printer to the Adobe PDF printer. Close the print menu and then do a reflow and link update of the document (ctrl-A, then F9 I think). This is needed to get the links correct since WORD reflows the document based on the printer (problem with them going to the wrong place).
    Printing to the Adobe PDF printer (the step of print to file is not needed, just print to the printer and the rest is automatic) does not include the links. PDF Maker is a PreProcessor for the Adobe PDF printer that adds PDF Marks to the PS file before it is sent to Distiller (OK, the printer when used normally creates a PS file and then invokes Distiller to complete the process - your steps did with the Adobe PDF printer is the same process done manually).
    Summary:
    1. Fix document after setting the printer to Adobe PDF.
    2. Use PDF Maker (create PDF button)

  • Problem in Converting Shapefile to SDO Layer

    Hi all,
    I am new to the Oracle Spatial database 10g (10.2.0.1.0). I got problem in Converting shapefile to sdo.
    My ESRI Shapefile (Tempshp.shp,Tempshp.shx,Tempshp.dbf) contain field name as "LEVEL".
    I can able to run the shp2sdo and "Tempshp.sql" and "Tempshp.ctl" files are all created without any problem.
    when i try to run the following command in SQLPlus
    @Tempshp.sql
    The following error message were generated
    LEVEL NUMBER,
    ERROR at line 4:
    ORA-00904: : invalid identifier
    May i know whats the actual problem, Is there any Reserved word/ keyword like LEVEL is present in oracle/ Spatial.
    Regards,
    Prema Selvam.
    Message was edited by:
    Prema Selvam
    Message was edited by:
    Prema Selvam

    Hello Ro,
    Thanks,
    If we are changing the field name LEVEL to Something like LEVELX, then whether we need to change the the LEVEL as LEVELX in .ctl also.
    If i am changing the Field name whether it will affect the spatial function such as join, etc..,
    Thanks & Regards,
    Prema Selvam.

  • Problem in converting reports  to PDF format - bug

    dear all,
    There is a problem in converting the reports in PDF format.
    The situation is that if we use the tool bar icon in SAP B1 to get the reports in PDF format, there are printing errors. The output PDF file does not contain the exact data that is in the report, the values are getting interchanged and mismatched.
    But if we do the same using the print in the PDF option in choose from printers window as we do regular pringting, the document is printed properly.
    what may be the cause for this bug like thing. How can we solve it??
    please help me..
    thanks and regards,
    Yeshwanth Prakash

    Check this SAP Note: 1089388     Incorrect value in exported PDF when Concat function is used
    [https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/smb_searchnotes/display.htm?note_langu=E&note_numm=1089388]

  • Problem in converting spool to pdf

    Hi Experts,
    I want an internal table to be converted to the PDF. For this RSPO_OPEN_SPOOLREQUEST, RSPO_WRITE_SPOOLREQUEST and RSPO_CLOSE_SPOOLREQUEST to create the spool. However, somehow the table tsp01 does not gets updated as a result i could not convert the data to PDF. Can any one help me how this problem could be solved.
    Thank.
    Warm Regards,
    Harshad.

    Hi,
    you can refer this sample code.
    DATA: t_otfdata_tab LIKE ITCOO OCCURS 0 WITH HEADER LINE.
    CALL FUNCTION 'CLOSE_FORM'
    TABLES
    OTFDATA = t_otfdata_tab
    fill the exceptions..
    IF SY-SUBRC = 0.
    ENDIF.
    then pass the t_otfdata_tab to this function module..
    CONSTANTS: c_pdf(03) VALUE 'PDF'.
    PDF File size
    DATA: w_file_size TYPE I.
    Internal Table to hold Form contents in PDF format
    DATA: t_pdfdata_tab LIKE tline OCCURS 0 WITH HEADER LINE.
    for converting. the output format from OTF to PDF
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
    FORMAT eq c_pdf
    IMPORTING
    BIN_FILESIZE = w_file_size
    TABLES
    OTF eq t_otfdata_tab
    LINES eq t_pdfdata_tab
    EXCEPTIONS...
    use these links, hope it will be useful to you....
    Problem in converting spool to PDF file
    Problem in converting the spool to PDF.
    Thanks and Regards,
    Ahamed.

  • Problem in converting some images

    Hi all,
    I have a problem when converting a word document in pdf (using acrobat 9). If i use the standard settinings, everything works fine. If I use personalised options to mantain bookmarks and links in the final pdf, some images (png) after the conversion appear with some black stripes on top of them.
    Does someone encountered the same problem?
    Thank You!

    Sorry for the delay in my response. I was on vacation.
    I tried following code (giving the type as related). But still it didn't work out :(
    I am sure i am doing some silly mistake. I guess mistake is in how i use cid:imageDo i need to use four unique cid tag if i attach four images? If yes can someone help me how? Thanks
    MimeMultipart multiPart = new MimeMultipart("related");
    MimeBodyPart msgBody = new MimeBodyPart();
    String htmlText = content+"<H1></H1><img src=\"cid:image\">";
    msgBody.setContent(htmlText, "text/html");
    multiPart.addBodyPart(msgBody);
    File folder = new File("./result");
    File[] listOfFiles = folder.listFiles();
    for (int i = 0; i < listOfFiles.length; i++)
    MimeBodyPart attachmentPart = new MimeBodyPart();
    FileDataSource fds = new FileDataSource(listOfFiles.getAbsolutePath());
    attachmentPart.setDataHandler(new DataHandler(fds));
    attachmentPart.setFileName(listOfFiles[i].getName());
    attachmentPart.setHeader("Content-Type", "image/png" );
    //attachmentPart.setDisposition("inline");
    attachmentPart.setHeader("Content-ID","image"+i);
    mp.addBodyPart(attachmentPart);
    System.out.println("Attached the file " + listOfFiles[i].getAbsolutePath());
    mess.setContent(multiPart);

  • Problem in converting to PDF

    Hi,
    i am facing a strange problem while converting the book file to pdf...
    Error message:
    %%[ ProductName: Distiller ]%%
    %%[Page: 1]%%
    %%[Page: 2]%%
    %%[ Error: ioerror; OffendingCommand: readstring ]%%
    Stack:
    (====;;;;;;::::9998877755554444222222222-\)&# ...)
    -file-
    -mark-
    -save-
    %%[ Flushing: rest of job (to end-of-file) will be ignored ]%%
    %%[ Warning: PostScript error. No PDF file produced. ] %%
    I think its with the encapsulated post script files I use in the book.
    please help me to resolve this issue...
    Thanks...

    PostScript language level 2 dates back to 1990. PostScript language level 3 was announced in 1996 with first devices shipping in 1997. Adobe Acrobat Distiller is effectively an Adobe PostScript 3 device as of Acrobat 4.0. At Adobe, we know of no problems associated with processing of properly generated PostScript language level 3 files by Distiller.
    In terms of what may appear in an EPS file, the major areas of difference would be in use of smooth-shaded gradients in language level 3 as opposed to adjacent similar polygons or images to represent gradients in language level 2.
    Ironically, changing the settings of the Adobe PDF PostScript printer driver instance for PostScript language level (the Distiller itself has no such setting) does
    not affect the placed EPS (or EPS derived from placed PDF) in your FrameMaker document. The PostScript text in the EPS is simply passed through the driver unchanged, regardless of the driver's PostScript language level setting, to the Distiller. The setting you changed affected only the PostScript generated from non-EPS components of your FrameMaker document.
    I cannot rationally explain the symptoms you experienced and why the driver setting change you made resolved the symptoms without looking at your files and knowing exactly how they were generated. It is possible that the problem has nothing to do whatsoever with your EPS files! :-)
    - Dov

  • Alignment problem in converting smartform printpreview into PDF

    Hi all,
    I am getting some alignment problem in converting smartform printpreview into PDF format, i.e the format of PDF is different from printpreviw of smartform.
    kindly suggest something so that alignment is not changed while converting to PDF.
    Regards,
    Sumalatha

    use below f.m to convert it into 255 characters....
         CALL FUNCTION 'QCE1_CONVERT'
            TABLES
              t_source_tab         = i_tline
              t_target_tab         = so_ali[]
            EXCEPTIONS
              convert_not_possible = 1
              OTHERS               = 2.

Maybe you are looking for

  • How can I transfer tags from a JPG to a RAW?

    I have another person tagging my photos but transferring my RAW files is time consuming. If I export the RAWs as JPGs, then have them tag the JPGs, can I then get those tags transferred to the RAW from which they came? Thanks, Ed Beck

  • How do I get IWS 4.1 to recognize a MySql JDBC driver?

    I have developed a web application the access a MySql database from a JSP using tomcat 3.3. I am now migrating the application to the production envionment, IPWS 4.1 SP7. I get a serverlet exception : no sutable driver when the JSP tries to connect u

  • IBook G4 blacks out without warning

    My sister has an iBook G4 and she tells me that she was reading something on a website and that out of nowhere, it just blacked out. She describes it as "like when someone turns off an old television". I have also tried turning it back on, but that d

  • My itunes wont connect to the internet after various attempts to fix it.

    i have tried various things to fix my itunes from restoring my ipod touch which does not work bc it cannot connect itunes to the internet to fix. ive also tried fixing the proxy, and firewalls, i keep getting unknown error 3212 when i try and access

  • Storing iTunes on external hard drive -- quick question

    I know how to save my iTunes library on an external hard drive, but how do I move my entire Itunes onto it? Do I just save the Itunes on the external drive instead of on the C drive? As it is now, all my music is stored on the external drive, but if