Converting a text string to a date in Discoverer

I've got a problem with a discoverer report which is that an item is pointing to a field in the Oracle table which is named as a segment4. This appears to be a generic field which stores any type of data, as it is based on the result of a flex-field in the application, so you could have dates, text, numbers etc. The problem is that the dates are stored in the table back to front i.e. 2004/10/19 00:00:00 and I need to be able to convert the date values so they are in the format DD-MON-YYYY as is this is the format that we use for all our reporting. When I try to apply any kind of date function it doesn't seem to work because it's a text field. I've used SUBSTR to get the first 10 characters and then used it again to split into day, month, year and then concatinated the values into one field in the correct order. This works to a certain degree but still doesn't recognise the value as being a date because because it doesn't sort them in order i.e. 20-06-2007 would appear before 30-06-2005. I'm not sure whether Discoverer could fix the problem or whether it may something the DBA may have to apply to the table. Does anyone have any suggestions to how I can get around this problem?
Thanks.
Joanne Hulme, Bolton Council.

Hi,
You can use TO_DATE(segment4, 'YYYY/MM/DD HH24:MI:SS') in a calculation to convert the segment to a oracle date type.
You can then format the date in anyway you need.
Rod West

Similar Messages

  • Converting a java string to a date.

    I am working on extending an EO and I have a situation where I must convert a string to a date before passing it to a method. The string is in the format "DD-MON-YYYY". I am using the following code and get an error "incompatible types: found: java.util.Date, required: oracle.jbo.domain.Date". Here is the code I am using:
    try {
    SimpleDateFormat df=new SimpleDateFormat("DD-MON-YYYY");
    oracle.jbo.domain.Date expdate=df.parse(expendituredate);
    setExpenditureItemDate(expdate);
    catch (Exception err) {
    Any ideas why the code I am using is not working? Is there another way to do this?
    Mike

    The difference is that
    D Day in year
    d      Day in month
    Hence when you used 22-Feb-2007 with "DD-MMM-yyyy", it took 22 as the 22nd day of the year and overrided the month value giving you 22nd January :)
    Cheers
    --Saroj                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Converting multiline text string to single line

    How do I convert a multiline text string into a single line text string

    Hi Bart,
    what's a multiline text string?
    1) You have an array of string: simply use "string concatenate" to convert from array to scalar string.
    2) Your string contains CR and/or NL characters: use "Search/Replace..." for this string, replace all EndOfLine chars by space (or which char you may prefer)...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Comparing two columns in two tables using partial text strings and copying data between tables

    I have two tables:
    The Vendor table is supplied by a clothing manufacturer and lists product data by row with a column that contains a unique manufacturer ID, such as T5C4.  In this table is a short product description and a long product description that I need to find and copy into the second table, Inventory.
    The Inventory table is an export from our Magento store.  Each row contains a unique inventory number in a column that includes but does not match the unique manufacturer ID from the Vendor table.  For example, the unique inventory number could be T5C4-W12, or RED-T5C4W12 or some other variation.
    For each product in Inventory, I need to find the matching product in Vendor, and then copy the short description and long description from Vendor to Inventory.
    Any tips?  Thanks!
    Karl

    Karl,
    Here's a start, as you requested.
    The formula for Our Inventory Row is:
    =IFERROR(MATCH("*"&A&"*", Our Inventory :: A, 0), "n/a")
    The formula for Brief Description in the inventory table is:
    =IFERROR(INDEX(ABC Products :: $A$1:$C$9,MATCH(ROW(), ABC Products :: $D, 0), 2), "n/a")
    The formula for the Full description in the inventory table is:
    =IFERROR(INDEX(ABC Products :: $A$1:$C$9,MATCH(ROW(), ABC Products :: $D, 0), 3), "n/a")
    The Manufacturer's table knows the concise product numbers, so it has the ability to search the Inventory table for it's product id's using wildcards and it then displays the line number of the item in the inventory table. The Inventory table can then search the manufacturer's table for its row number and can reference the brief and full descriptions.
    This approach has a serious limitation. It will only find the first occurrence in the inventory. Now, if you want to accept this, you can sort all the found descriptions and pull them out of the inventory table, and then the next product in line will display it's description too.
    I wish I could do better with this, but it's all I can come up with at this point, knowing only what you have told me.
    Jerry

  • Converting 3 Strings to 1 Date?

    Hi first of i am very new at this sql. But my problem is that i am haveing 3 combo boxes in java. 1 with dd 1 with mm and 1 with yyyy. How do i convert these 3 strings into 1 date format? Writing the Gui in java.
    It is to a booking system so i need it for a fromdate and then the same in a todate function. Hope u understand my problem.
    Best regards
    Jakob

    take care of 1 digit days/months. (ex 31-2 != 3-12). So if you have digits, you could use to_date(d||'.'||m||'.'||y,'DD.MM.YYYY)Message was edited by:
    Laurent Schneider
    31-2 very clever example ! Sorry about that...

  • Date Format Picture ends before converting entire input string..

    Hi all
    i am creating a report in 10g.. in which i want to convert Emp_lump_sum (number)  to character .I have created a formula column in which i have written a function in the formula column and assign that formula column to the text field in which i want the result.
    when the report run i get the following error....
    ORA-01830: date format picture ends before converting entire input string..
    i have tried with a attribute EMP_NO (Varchar2(30)), it shows the result but when i add EMP_LUMP_SUM (NUMBER) , it show the above error. on the database side i get the same error.
    Database : 11g
    OS :     Windows server 2003
    reports   : 10g
    any help will be thankful..
    Function i wrote behind the formula coloumn is..
    function CF_1Formula return CHAR is
    xy varchar2(100);
    begin
      select to_char(to_date(emp_lump_sum,'j'),'jsp') into xy from fms_111_form4_tr;
        return xy;
        --xy := f_19;
    end;

    Hello:
    Try to use a database function and call it from reports.
    Regards,

  • Convert String to sql date

    hi all,
    i have a date in string format Tue, 06 Feb 2007 12:38:17 GMT
    How do i convert it to sql datetime.
    Date date = new Date("Tue, 06 Feb 2007 12:38:17 GMT");// creating date
              java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(
                        "yyyy-MM-dd HH:mm:ss");// format definition
              java.sql.Time pubDate = java.sql.Time.valueOf(sdf.format(date));
              System.out.println(pubDate);This code gives me java.lang.NumberFormatException.
    Thanks in advance.......
    VikraM

    is "EEE d MMM yyyy HH:mm:ss Z" your default data format
    if not your first constructor will not parse date properly so your date object contains invalid date, when you try to format it it throws exception.
    check it
    sudhir nimavat

  • Convert text string file to object array without outputting to file first?

    I have a log file that is just a text string file which is appended to with Out-File.  If the log file does not exist I pipe headers to it so that I can import the data as CSV.  For example:
    DATA.LOG
    DATE,TIME,RESPONSE_TIME
    05-28-2014, 14:47, 132
    05-28-2014, 14:50, 94
    05-28-2014, 14:53, 72
    I'm using Microsoft Chart Controls to graph the data; it takes it in via CSV format.  If I'm going to chart all the entries in DATA.LOG I can simply IMPORT-CSV DATA.LOG.  But I only want to graph the 20 most recent entries.
    Perhaps there is a better way to do this, but to maintain the header and get the 20 most recent entries I'm using select.
    $DATA+=Get-Content .\data.log | select -first 1
    $DATA+=Get-Content .\data.log | select -last 20
    The problem is $DATA is of type system string so I can't use it directly with Chart Controls; I need to get it in CSV format first.  I can Out-File $DATA and then use IMPORT-CSV.  But I'd prefer to not have to use
    the temporary file.  Any suggestions on how I can accomplish this objective? 

    Import-CSV creates an object with the 'header' becoming the named values in the array.  The code I posted does the same thing as your 4 lines of code in one line of code:
    Much more quickly:
    PS C:\temp> (1..1000 | measure-command {import-csv .\data.log | select -last 2}).totalseconds
    0.4792951
    PS C:\temp> (1..1000 | measure-command {$DATATMP=@();$DATATMP+=Get-Content .\data.log | select -first 1;$DATATMP+=Get-Content .\data.log | select -last 2;ConvertFrom-CSV $DATATMP}).totalseconds
    1.6227726
    You're more than welcome to use whatever code you want, but if you want to improve your Powershell knowledge you should try to understand the object model around which Powershell is built, it is powerful and efficient.
    I hope this post has helped!

  • Converting a text file into a String

    I need to convert a text file (in whatever format, in my case it would be xml and xsl files) in a String.
    I made this methods:
    public static String createStringFromFile(File f) {
            StringBuffer buf = new StringBuffer();
            try {
                FileInputStream fInp = new FileInputStream(f);
                byte[] byteArray = new byte[fInp.available()];
                int bLetti = fInp.read(byteArray);  
                if (bLetti == fInp.available()) {
                    for (int i=0; i<fInp.available(); i++)
                        buf.append(Byte.toString(byteArray));
    else
    throw (new IOException("Errore nella lettura del file"));
    fInp.close();
    } catch (Exception e) {
    ErrorManager.getError(e);
    return (buf.toString());
    public static String createStringFromFile(String fileName) {
    StringBuffer buf = new StringBuffer();
    try {
    FileInputStream fInp = new FileInputStream(fileName);
    byte[] byteArray = new byte[fInp.available()];
    int bLetti = fInp.read(byteArray);
    if (bLetti == fInp.available()) {
    for (int i=0; i<fInp.available(); i++)
    buf.append(Byte.toString(byteArray[i]));
    else
    throw (new IOException("Errore nella lettura del file"));
    fInp.close();
    } catch (Exception e) {
    ErrorManager.getError(e);
    return (buf.toString());
    There are no compilation or runtime errors, but the result string is empty. Not null, empty. What should I do? :)

    Do you really want to use bytes and so on when java does it all for you?
    Here's how I did it, hope it's useful.
    public String getFileAsString(String fileName){
         StringBuffer buffer = new StringBuffer();
         try{
         BufferedReader bRead = new BufferedReader(new FileReader(new File(fileName)));
         String str = "";
         while( (str = bRead.readLine()) != null ){
              buffer.append(str);
         }//end while
         bRead.close();
         }catch(Exception e){
         System.err.println("in getFileAsString(): " + e.toString());
         }//end try
         return buffer.toString();
    }//end getAsString()

  • Error in converting character string to smalldatetime data type

    I've installed SQL Server 2000 on my new laptop and Crystal Report XI, out of sudden, the Crystal Report to certain view can't run and I got the following error:
    Details: 22007 [Microsoft][ODBC SQL Server Driver][SQL SERVER]Syntax Error cnverting character string to smalldatetime data type.
    Any suggestions?
    Hannah

    Here is the view the err is complaining about:
    SELECT     TOP 100 PERCENT Cur.Closed_Month, Cur.Closed_Year, Cur.Incidents_Closed, Prev.Incidents_Closed AS PrevIncidents_Closed,
                          YrAgo.Incidents_Closed AS YearIncidents_Closed
    FROM         (SELECT     Closed_Month, Closed_Year, Incidents_Closed
                           FROM          dbo.Incidents_Closed) Cur INNER JOIN
                              (SELECT     Month(CONVERT(datetime, CAST(closed_month AS varchar) + '/01/' + CAST(closed_year AS varchar), 101) + 32) AS PrevMonth,
                                                       year(CONVERT(datetime, CAST(closed_month AS varchar) + '/01/' + CAST(closed_year AS varchar), 101) + 32) AS PrevYear,
                                                       Incidents_Closed
                                FROM          dbo.Incidents_Closed) Prev ON Cur.Closed_Month = Prev.PrevMonth AND Cur.Closed_Year = Prev.PrevYear INNER JOIN
                              (SELECT     Month(CONVERT(smalldatetime, CAST(closed_month AS varchar) + '/01/' + CAST(closed_year AS varchar), 101) + 366) AS PrevMonth,
                                                       year(CONVERT(smalldatetime, CAST(closed_month AS varchar) + '/01/' + CAST(closed_year AS varchar), 101) + 366) AS PrevYear,
                                                       Incidents_Closed
                                FROM          dbo.Incidents_Closed) YrAgo ON Cur.Closed_Month = YrAgo.PrevMonth AND Cur.Closed_Year = YrAgo.PrevYear
    What confused me is that it works fine with my previous laptop. I wonder if there is any patch in Crystal Report or SQL server that used to support certain functions but not support them anymore....
    Thanks
    Hannah

  • Converting part of the string to a date and subtract with sysdate.

    HINT! In order solve this you must know how the pnr is assembled. Study this:
    650323-5510, we only need the first six characters. They inform us about when the person (car owner) was born. In this case it is 23 Mars 1965. You have to use several oracle built-in-functions to solve this. Hint! Begin by converting part of the string to a date and subtract with sysdate.
    select to_char(to_date(cast(pnr,'YYMMDDMM'))) from car_owner;
    please what am i doing wrong. i need the result to be something like this
    Hans, Rosenboll, 59,6 years.

    Hi.
    The main problem here is you have only last two digits of year. That could be the problem in a couple of years from now, when somebody born after 2k would get in to your database. For now if we ignore this problem the right solution would be :
    <code>
    SELECT months_between(trunc(SYSDATE),
    to_date('19' || substr('650323-5510',
    1,
    6),
    'YYYYMMDD')) / 12 years_old
    FROM dual
    </code>
    Suppose you are expecting the age of the car owner as a result above code will give you that. One again notice the '19' I appended.
    Best regards.

  • How to convert a "text variable" to String with plugin

    Hello,
    I am currently developing a InDesign (CS5) plugin, where I need to manipulate text variable.
    From the plugin I want to convert the "text variable" to string (in principle I should use the method "VariableToString (..)" of "ITextVariable")"
    My problem is, how to find the text varial from its name (I think I should use the method "FindLocationsUsed(..)" of "ITextVariableSuite") and then convert it to String
    I don't know how to use interfaces ITextVariable and ITextVariableSuite
    Plugin implemented in C++ language
    thank you

         InputStreamReader in=new InputStreamReader(fis);
          StringWriter out=new StringWriter();
          char[] buffer=new char[8192];
          int sizeRead;
          while ( ( sizeRead=in.read(buffer, 0, 8192) ) != -1 )
            out.write(buffer, 0, sizeRead);
         String content=out.toString();

  • ORA-01830: date format picture ends before converting entire input string at OCI call OCIStmtFetch

    Hi all,
    We are trying to create a BIP Data Model based on an Answer, but after selecting report, it hangs when I try to Apply to create a query based on Oracle BI. When I try to open the query in aswers, going to results tab I'm getting this error (OBIEE 11.1.1.6.2):
    ORA-01830: date format picture ends before converting entire input string at OCI call OCIStmtFetch
    I suppose that BIP data model is not able to create it because of this error. But this answer is working fine inside dashboards, etc. It only does not work when editing it. Query is doing something like this: "USING "- Collection Attributes"."Due Date" >= TIMESTAMPADD(SQL_TSI_DAY, -30, CAST ('01/04/2009' AS DATE))"
    Any ideas?

    Solved watching date format in generated SQL and changing default date format in presentation variables default values inside criteria according to SQL format.

  • How to convert a string into orcle date format

    i need some information about converting string into date format.i have string like '20-SEP-05' .so we have to convert into date formate like yy-mm-dd' (2005-09-20).how can we do it.

    Here's some code to help. I can't remember what method uses what format though
      public static java.sql.Date sqlDateValueOf( String dateString ) {
        String stringDate = null;
        if ( dateString == null || dateString.length() < 10 ) return null;
        String strDay = "";
        String strMonth = "";
        String strYear = "";
        if ( dateString.substring(4,5).equals( "-" ) ) {
          strDay = dateString.substring(8, 10);
          if ( strDay.length() < 2 ) strDay = "0" + strDay;
          strMonth = dateString.substring(5, 7);
          strMonth = dateString.valueOf(Integer.parseInt(strMonth) - 1);
          if ( strMonth.length() < 2 ) strMonth = "0" + strMonth;
          strYear = dateString.substring(0, 4);
          stringDate = strDay + "-" + strMonth + "-" + strYear;
        else if ( dateString.substring(2,3).equals( "-" ) ) {
          strDay = dateString.substring(0, 2);
          if ( strDay.length() < 2 ) strDay = "0" + strDay;
          strMonth = dateString.substring(3, 5);
          strMonth = String.valueOf(Integer.parseInt(strMonth) - 1);
          if ( strMonth.length() < 2 ) strMonth = "0" + strMonth;
          strYear = dateString.substring(6, 10);
          stringDate = strDay + "-" + strMonth + "-" + strYear;
        Calendar cal = Calendar.getInstance();
        cal.set( Calendar.YEAR, Integer.parseInt( strYear ) );
        cal.set( Calendar.MONTH, Integer.parseInt( strMonth ) );
        cal.set( Calendar.DAY_OF_MONTH, Integer.parseInt( strDay ) );
        java.sql.Date outDate = new java.sql.Date( cal.getTimeInMillis() );
        return outDate;
      public static String toDateString( java.util.Date date) {
        if ( date == null || date.toString().length() < 10 ) return null;
        String outDate = "";
        SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
        outDate = df.format( date );
        return outDate;
      public static String toDateString( java.sql.Date date) {
        if ( date == null || date.toString().length() < 10 ) return null;
        String outDate = "";
        SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
        outDate = df.format( date );
        return outDate;
      public static String toDateString( java.sql.Date date, String format) {
        if ( date == null || date.toString().length() < 10 ) return null;
        String outDate = "";
        SimpleDateFormat df = new SimpleDateFormat( format );
        outDate = df.format( date );
        return outDate;
      public static String toDateString( java.sql.Timestamp date) {
        if ( date == null || date.toString().length() < 10 ) return null;
        String outDate = "";
        SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
        outDate = df.format( date );
        return outDate;
      }

  • How to convert a text file content to String in JSP?

    Hi,
    I need to read the content of a text file and convert it into String and display it on to a JSP file.
    But the codings below don't work. Please advise me on how can i display the text file content.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    File adCheck = new File("list.txt");
    fis = new FileInputStream(adCheck);
    int Length = adCheck.length();
    byte arr[] = new byte[Length];
    int dataRead = 0;
    int totalData = 0;
    while(totalData <Length)
         dataRead = fis.read(arr,totalData,Length);
         totalData += dataRead;
    String Content = new String(arr);//byte array converted to String
    arr = null;

         InputStreamReader in=new InputStreamReader(fis);
          StringWriter out=new StringWriter();
          char[] buffer=new char[8192];
          int sizeRead;
          while ( ( sizeRead=in.read(buffer, 0, 8192) ) != -1 )
            out.write(buffer, 0, sizeRead);
         String content=out.toString();

Maybe you are looking for

  • How can I save colors of text by copy and paste from a strange application

    Hi! When I copy colored text from a strange application to paste it into pages (4.0.2) all text is black. The colors disappear. When I look at the clipboard, I see the correct colors. In AppleWorks, MS-Office and OpenOffice the colors are copied corr

  • Session state always invalid after login

    Hello community, i have a functional login process which uses my own login with username and password. After login i branch to application start page, but this session now is different from the start login session, so every login is invalid and will

  • Example font subset with non-unicode output

    Hi, I am searching for an example to use a TTF Font as font subset in PDF but without UTF16 encoding. Is this even possible? Something similar to 7 0 obj <</Type /Font /Subtype /Type0 /BaseFont /AAAAAD+Arial/Encoding /Identity-H /DescendantFonts [9 0

  • LSMW for Transaction Code FB41

    Hi, Can any one let me know LSMW - direct input method or BAPI (Bussiness Object) to update data using transaction code FB41. I have used direct input method RFBIBL00, but this standard direct input method is not supported for transaction code FB41.

  • Open all files in folder using Javascript

    Let's say I want to open all the files in a particular folder, without knowing the names of those files. Any ideas? Thanks!