SQL QUERY - Dates

Hi Everyone
I want to chabge a format for a date which is stored as Text in this format
'2008/04/01 00:00:00'.I tried to_char but it returns an error message saying
"The attempted conversion of a character string to a number failed because the character string was not a valid numeric literal"
Thanking in advance

use to_date
Select to_date('2008/04/01 00:00:00','rrrr/dd/mm hh24:mi:ss') d_date From dual;Message was edited by:
Nicloei W

Similar Messages

  • Is there a way to consolidate calculations used in SQL Query Data Sets?

    I am building SQL Query Data Sets against multiple DB Views which all have different date formats. I have the date parameter working well, but want to consolidate the changes that I have to do to it especially for the quarter. For example the SQL against a monthly view would use "where year_month > to_char(:ST_DATE, 'YYYY-MM')" which is not too hard, but to make that work for the quarterly view I need several concats and a decode to get a "> '2012-Q2'". I would like not to have to do this within every where clause. I had put this into a global element hoping to use that in a filter for the data set, but the filter does not have access to global elements only parameters.
    Is there any way to refer to a calculated global element from the data set to do this? I am using Layout Templates, so even if I wanted to I could not do the condition within the template.
         Thanks,
         Rick

    Change the following line to include the red coloured parts
    <div class="MasterColumn" spry:repeat="ds4" spry:setrow="ds4" spry:hover="MasterColumnHover" spry:select="MasterColumnSelected">
      <span>{Dsp_#}</span><span>{Dsp_WkDay}</span><span>{Dsp_Event}</span>
    </div>
    The add the following style rule to your document:
    .MasterColumn span {
        display: inline-block;
    I hope this helps.
    Ben

  • With clause in SQL query data model

    Hello!
    isn't it possible to use the with clause in sql query data models?
    for example following query:
    WITH
    a_test as (
    select dummy from dual
    select *
    from a_test
    brings up a "XML Parsing Error: no element found"-error...
    BR Paul

    I tried a slightly different query (see below) and the query worked fine and retrieved data.. I did not get any errors.
    WITH
    a_test as (
    select 'dummy' from dual
    select *
    from a_test
    This works as well.. retrieving the value of the parameter
    WITH
    a_test as (
    select :Test_ID from dual
    select *
    from a_test
    thanks,
    BIPuser

  • SQL Concat function seem not to work properly in SQL query data model. BIP 11g

    I try to use this function to show entire name CONCAT(name, ' ', surname) and it doesnt show the surname. it looks like it only tooks 2 arguments. I use it with the option "Add element by expression" within a SQL Query - Data set.
    Lucia

    i don't believe you
    please post more info, may be screen or sql or some more useful statement
    CONCAT(name, ' ', surname) and it doesnt show the surname
    may be because for some case "surname" is empty  or may be you incorrect use concat function
    one way mentioned by BluShadow is " || " operator  - http://docs.oracle.com/cd/B28359_01/server.111/b28286/operators003.htm#SQLRF51156
    and another is concat function http://docs.oracle.com/cd/B28359_01/server.111/b28286/functions026.htm#SQLRF00619
    so for your case it can be like
    CONCAT(CONCAT(name, ' '), surname)

  • Different LOV behavior between SQL query data model and data template

    I have noticed different behavior when using parameters linked to list of values (LOV) of type menu with the multiple selection option enabled and a SQL query data model vs a data template. Here's the example because that first sentence was probably really confusing.
    SQL Query:
    select
    plmc.MonthCode, plmc.ModalityDim, plmc.ModalityName,plmc.RegionDim
    from
    DataOut.dbo.PatientLabMonthlyCross plmc
    where
    plmc.MonthCode = 200202
    and plmc.RegionDim = 1209
    and 1 =
    case
    when coalesce(:modalityDim,null) is null
    then 1
    else
    case
    when plmc.ModalityDim in (:modalityDim)
    then 1
    else 0
    end
    end
    Putting BI Publisher into debug mode, defining a data model of type SQL Query, defining a parameter called :modalityDim linked to a LOV that allows multiple selections, and selecting a couple of values from the LOV the output of the prepared statement is:
    [081607_122647956][][STATEMENT] Sql Query : select
    plmc.MonthCode,
    plmc.ModalityDim,
    plmc.ModalityName,
    plmc.RegionDim
    from
    DataOut.dbo.PatientLabMonthlyCross plmc
    where
    plmc.MonthCode = 200202
    and plmc.RegionDim = 1209
    and 1 =
    case
    when coalesce(?,?,null) is null
    then 1
    else
    case
    when plmc.ModalityDim in (?,?)
    then 1
    else 0
    end
    end
    [081607_122647956][][STATEMENT] 1:6
    [081607_122647956][][STATEMENT] 2:7
    [081607_122647956][][STATEMENT] 3:6
    [081607_122647956][][STATEMENT] 4:7
    [081607_122654713][][EVENT] Data Generation Completed...
    [081607_122654713][][EVENT] Total Data Generation Time 7.0 seconds
    Note how the bind variable :modalityDim was changed into two parameters in the prepared statement.
    When I use this same SQL Query in a data template the output is:
    [081607_012113018][][STATEMENT] Sql Query : select
    plmc.MonthCode,
    plmc.ModalityDim,
    plmc.ModalityName,
    plmc.RegionDim
    from
    DataOut.dbo.PatientLabMonthlyCross plmc
    where
    plmc.MonthCode = 200202
    and plmc.RegionDim = 1209
    and 1 =
    case
    when coalesce(?,null) is null
    then 1
    else
    case
    when plmc.ModalityDim in (?)
    then 1
    else 0
    end
    end
    [081607_012113018][][STATEMENT] 1:'6','7'
    [081607_012113018][][STATEMENT] 2:'6','7'
    [081607_012113574][][EXCEPTION] java.sql.SQLException: Syntax error converting the nvarchar value ''6','7'' to a column of data type int.
    Note the exception because it is trying to convert the multiple parameter values.
    Am I doing something completely wrong here? I really need to use a data template because I will need to link a couple of queries together from different database vendors.
    -mark

    This is for 10.1.3.4 - because in 11g every SQL query is automatially part of a data model.
    In 10g SQL query is for simple unrelated SQL queries.
    If you need to use advance features such as:
    a) multiple SQL queries that are joined in master-detail relation ships
    b) before/after report triggers
    Then you will need to use the data template, which is an XML description
    of the queries, links, and PL/SQL calls.
    hope that helps,
    Klaus

  • SQL Query Data Model Question

    Hi All,
    I'm new to XMLPublisher so i'll try to explain the best i can the problem i'm having creating a Data Model for my report.
    I'm using Database XE and have installed XMLPublisher, as XE is extremely flexible in creating apps i'm having huge trouble finding a reporting solution for my applicaiton. I have created an app to track and control time and expense which i want to generate timesheet, expense sheets, invoice etc from.
    Having done some read i think XML is the best approach for me however i'm having huge troubles with my data model.
    EXAMPLE:
    I have 2 tables to start with, first table holds client information and the second table holds project information. One client can have many projects.
    When i create the Data Model using SQL i get the obvious problem that when a client has more then one project my XML structure is incorrect.
    SELECT gc.name AS CLIENT,
    gp.name AS PROJECT
    FROM gte_client gc,
    gte_project gp
    WHERE gc.client_id = gp.client_id(+)
    The above SQL creates the following XML
    - <ROWSET>
    - <ROW>
    <NAME>Symatrix Ltd</NAME>
    <NAME>Symatrix Pre-Sales</NAME>
    </ROW>
    - <ROW>
    <NAME>Aston Carter</NAME>
    <NAME>MOD</NAME>
    </ROW>
    - <ROW>
    <NAME>Symatrix Ltd</NAME>
    <NAME>Fujitsu</NAME>
    </ROW>
    </ROWSET>
    Obvious problem here is the fact that client Symatrix appears twice as there are 2 projects.
    I have tried to write SQL/XML and i think i'm beginning to understand the structure of the XML functions however XMLPublisher doesn't appear to understand the syntax when creating a SQL Query for the data model.
    I hope all this makes sense.
    Kind Regards
    Glen

    Hi All,
    Ok, so with a little searching through documents and articles on the web i found this information.
    http://blogs.oracle.com/xmlpublisher/2006/05/05#a38
    this details the exact thing i'm trying to achieve so anyone else who searches this forum with a similar problem check this out.
    Regards
    Glen

  • Need help with sql query dates

    Hi,
    I have a sql query where i need to extract some info between given dates. The where clause of this query is as follows:
    WHERE CPD_BUS_UNIT=:ESI_PRM_1
    AND CPD_VOUCHER_DATE >= :P_DATE_FROM
    AND CPD_VOUCHER_DATE < (:P_DATE_TO+1)
    When i execute the query in toad, i can view the data but not the execution plan.It gives an error ORA-00932-Inconsistent Datatypes.
    But when i remove (+1) from :P_DATE_TO, i can c the execution plan and data. Will the data be different from the previous one.
    Please suggest how to rewrite the query.

    Can you please give it a try?
    WHERE CPD_BUS_UNIT=:ESI_PRM_1
    AND CPD_VOUCHER_DATE >= :to_date(P_DATE_FROM)
    AND CPD_VOUCHER_DATE < (to_date(:P_DATE_TO)+1) Regards

  • How to get sql query data and write into csv file?

    I am writing to seek help, in how can I create bat. script which can execute the following logic:
    connection to the database
    run sql query
    create CSV file
    output query data, into CSV file
    save the CSV file
    osql
    -S 84.18.111.111
    -U adw
    -P rem
    -i "c:\query.sql"
    send ""
    sed -e 's/,\s\+/,/g' MCI_04Dec2014.csv > localNoSpaces.csv
    -o "c:\MCI_04Dec2014.csv"
    This what i have so far, and I am little struggling with the logic after creating CSV file. I am unable to get the above script to work, please advice further, where I may be going wrong. 
    Can you create if statement logic within window's script, to check for null parameters or data feeds?
    Any hints would be most appreciated. 

    Thank you for your reply. 
    Apology for posting the code irrelevant to the forum, as I am still novice scripting user.  
    My goal is to create window's script which can compute the above logic and send the final output file (csv), to FTP folder. 
    Can this logic be implemented via bat. script, if so, is there a example or tutorial i could follow, in order to achieve my task. 
    Any help would be much appreciated. 

  • JSTL sql:query date field has zero time part

    I have a little JSP where I am using JSTL to do a query against a table "ph_application" that has a date field "rundate". This field has many different dates and times in it.
    Here is the code snippet:
    <sql:setDataSource url="jdbc:oracle:thin:@oraprd02:1521:ipp4" user="site" password="pmc_site"/>
    <sql:query var="application" sql="select * from ph_application"/>
    <c:forEach items="${application.rows}" var="row">
    <tr>
    <td><c:out value="${row.name}" default=" " escapeXml="false"/></td>
    <td><fmt:formatDate value="${row.rundate}" type="both"/></td>
    </tr>
    </c:forEach>
    The resulting date/time output always has a 12:00:00 AM time regardless of what is actually in the table. I have changed the fmt:formatDate to a c:out of the row.rundate.time value and it appears that the time part of the date is actually zero at this point.
    Is there an inconsistancy between the oracle date type and what JSTL is expecting (somewhere)?
    Any help and/or verification is appreciated.
    Richard

    I'm running this from within JDeveloper 10g.

  • Limitation of SQL-Query data source !?

    Hello,
    I faced a situation that required the use of "case ... when ... then ...end" in my select-statement defining the data source. But I doesn't seem to work! I checked the statement in sql developer and it worked fine!
    Is there any idea about that?
    Thanks in advance.
    Dirk

    Hi Tim,
    thank you for your response - I created a sample query of what I used and it looks like this one:
    select col1
    ,col2
    , case col2 when '12' then (select a2.col2 from a2 where a2.col1 = a1.col1 )
    when '13' then (select a3.col2 from a3 where a3.col1 = a1.col1 )
         end
    from a1
    Dirk

  • Plsql procedure with sql query data

    plsql newbie(learning sql): please excuse for asking a basic plsql question
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod on windows server 2003
    PL/SQL Release 10.2.0.1.0 - Production
    "CORE     10.2.0.1.0     Production"
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    CREATE OR REPLACE PROCEDURE p_check
    AS
    v1 NUMBER(20,0);
    BEGIN
    SELECT count(*) INTO v1
    FROM ad_reg;
    dbms_output.put_line(v1);
    end;
    inserts the number of rows in the table ad_reg into v1
    and displays v1 by using dbms_output
    i want my procedure to return table data
    CREATE TABLE "TEST_SH"
    "TEXT_ID" NUMBER,
    "TEXT" CLOB
    Insert into TEST_SH (TEXT_ID) values (1);
    Insert into TEST_SH (TEXT_ID) values (2);
    Insert into TEST_SH (TEXT_ID) values (3);
    Insert into TEST_SH (TEXT_ID) values (4);
    there will be a way with which i can see all the data(select * from test_sh) as the output of the plsql procedure
    1.please tel me what to google
    2.please guide me with a site or tell what is actually used and help me
    3.or post an example here
    thank you much
    Edited by: 946207 on Nov 20, 2012 2:05 PM

    946207 wrote:
    there will be a way with which i can see all the data(select * from test_sh) as the output of the plsql procedurePL/SQL is
    a) nothing at all like T-SQL
    b) two different languages, PL (Programming Logic) and SQL
    SQL is used to access data in the Oracle database. So select * from test_sh is the correct statement to access the data.
    The client can make execute this SQL statement itself. And view the data. However, this requires the client to understand the SQL language, and the database model. Which is typically not that you want. You want to abstract that from the client.
    Why would you want the client to deal with the complexities of the SQL language? Or deal with the complexities of your database model in Oracle?
    So instead of the client doing SQL, PL/SQL can do it on behalf of the client. The client uses PL/SQL as an API - in a similar fashion as the client would use any other API.
    The PL/SQL code determines the SQL statement - and returns a SQL cursor handle to the client. The client then simply uses the SQL cursor that the PL/SQL code created for it (and the client needs to close the SQL cursor when done, so as to not cause server resource leakage).
    E.g. (using PL/SQL as an API to abstract SQL and the data model)
    create or replace procedure TestProc( c out sys_refcursor ) is
    begin
      open c for select * from test_sh order by 1;
    end;The client then calls TestProc and gets a reference cursor handle. E.g. (the client call to Oracle):
    begin
      TestProc( c => :1 );
    end;The client needs to supply a host (client language) bind variable of type cursor, as value for bind variable +:1+.
    This is the correct way to deal with PL/SQL and cursors from a client GUI/language perspective. Any other method, like using PL/SQL to cache SQL data as a collection, is usually very wrong.

  • Small Validation in sql Query Date range..

    hi.
    I need Some suggestions for validating the Date.
    In customization form From date and to date i given.
    like
    01/08/2014 and 30/08/2014..
    Second time if  they give...
    i can validate like below
    select  DocEntry from  [@PR_OTIMESHEET] where U_frmdate >='20140801' and U_todate <='20140830'
    It's fine everything is fine. but.
    if i give like from date 15/08/2014 and 30/08/2014 it should be validate and stop it..
    if i run the  above query by replace the dates it is not working..
    Simply.
    Date is  200   to  300 if they give first time it will be save in db.
    second time if i give 150 to 400 it should not accept bcz 150 all ready comes between 200 to 300
    How can i restrict it.

    Hi,
    If your question is related to SDK, please post it there.
    Thanks,
    Gordon

  • Sql query data horizontally with sum and condition in a row

    I am trying to get data from the following query in a row with total but not succeed and getting error message. Please help and advise.
    Select empid,name,country,
    sum(case category when 'JOB' then sum(core+RR) else 0 end) as 'JOB-Sum',
    sum(case category when 'PRIVATE' then sum(core+PP) else 0 end) as 'PRIVATE-Sum',
    group by empid,name,country
    Note: Following query is good for getting result in one row but i have to put sum calculation with 'THEN' and want result in a row.
    SELECT ID, MAX(case when Col1 = 'Yes' then 1 else 0 end) AS Col1,
    MAX(case when Col2 = 'Yes' then 1 else 0 end) AS Col2
    FROM MyTable
    GROUP BY ID

    Please show some sample data and expected output.
    Regards,
    Rob.

  • SQL Query date question

    Hello,
    I'm searching a query that would display me the number of rows made of a table for the last 4 weeks, grouped by each week.
    I basicly have the query but I don't think it will be correct when we go to the next year.
    Does anyone know how I can solve this problem?
    Select count(*),to_char( create_dt, 'iw' )
    from dossiers
    where to_char( create_dt, 'iw' ) > to_char(SYSDATE, 'iw') - 4
    group by to_char( create_dt, 'iw' )
    order by to_char( create_dt, 'iw' ) desc;
    Thanks in advance
    OLI

    This is what I use to count all my audits for the past 4 weeks:
    T10> SELECT TRUNC(weeks.start_date) || ' - ' || TRUNC(weeks.start_date + 6)  audit_date_span
      2       , COUNT(*)  count
      3    FROM asset_audits,
      4         (
      5           SELECT NEXT_DAY(
      6                    ADD_MONTHS(SYSDATE, -1) - 1
      7                  , 'SUNDAY') + ((ROWNUM - 1) * 7) start_date
      8             FROM (
      9                    SELECT 1
    10                      FROM DUAL
    11                   CONNECT BY LEVEL < 6
    12                  )
    13         ) weeks
    14   WHERE TRUNC(audit_date) BETWEEN TRUNC(weeks.start_date) AND TRUNC(weeks.start_date + 6)
    15   GROUP BY TRUNC(weeks.start_date) || ' - ' || TRUNC(weeks.start_date + 6)
    16   ORDER BY TO_DATE(SUBSTR(audit_date_span, 1, 9), 'DD-MON-YY') ASC
    17  /
    AUDIT_DATE_SPAN                COUNT
    29-OCT-2006 - 04-NOV-2006        105
    05-NOV-2006 - 11-NOV-2006        201
    12-NOV-2006 - 18-NOV-2006        120
    19-NOV-2006 - 25-NOV-2006        664
    4 rows selected.Cheers.

  • Setting Default value with SQL Query as Data Model

    Hi All,
    I am developing report based on SQL query.date set as 'SQL Query'. I have created two params start-date and end-date. I am fetching records from database between these two dates.
    I want to populate sysdate as a default values. I do not want to use datatemplate approach i mean using beforeReport trigger.
    Thansk,
    Vara

    Hi Vara,
    To set the default value for one of your parameters to SYSDATE you need to enter:
    {$SYSDATE()$}
    in the Default Value text box
    Is this what you require?
    Cheers
    Andy

Maybe you are looking for

  • I'm getting error code -54 when trying to connect to iTunes store...

    Hello, I have been receiving the following message code all week when trying to connect to the store: "iTunes could not connect to the iTunes Store, An unknown error occurred (-54). Make sure your network connection is active and try again" My intern

  • Unable to add web part to SharePoint 2013 page

    hello, My account has full control on the site collection, and when I edit the page and click on the Add a Web Part, nothing happens.  I would expect to have a list of web parts that I can select from, but this does not appear.  What can I do to enab

  • How to configure new mail notification?

    Hi, I want to set up SAP so that when a user receives a new mail in his/her SAP-mail inbox the system sends a notification to that user's email-adress (smtp-address) so that the notification will appear in Outlook. How can I do this? Regards, Thor-Eg

  • Table for OI

    I want all the open  line items of particular GL,where in some documents customer is also ther. Please let me know the table or... Thnks jabeen

  • Help with batch converting to change all videos to same size...720x480

    i need help batch converting all my .mov files to the same dimensions of 720x480...but i don't want to lose quality i just want to change the size...any suggestions in programs?