DATE FORMAT Conversion FOR SQL Reports

Hi,
Am building a report and am stuck here where this piece of code that throws the following error
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
My query goes some thing like this
DECLARE @StartDate varchar(15),
@EndDate Varchar(15)
SELECT @StartDate = '01/08/2014',
@EndDate = '31/08/2014'
SELECT DISTINCT
[Operation] = CASE WHEN p.DATE_OF_START BETWEEN @StartDate AND @EndDate THEN 'Add'
ELSE 'Update' END
FROM SNZ_HR_Reporting_POSMGNT as s
LEFT OUTER JOIN PERSON as p on s.EMP_NO = p.EMP_NO
WHERE s.CHANGE_DATE BETWEEN @StartDate AND @EndDate
The date format in the column DATE_OF_START  is like yyyy-mm-dd 00.00.00.000 .
My question is how to convert this format to dd/mm/yyyy format and execute the queries
Many Thanks,
Bhanu

SQL Date Format:
http://www.sql-server-helper.com/tips/date-formats.aspx
Please Mark This As Answer if it helps to solve the issue

Similar Messages

  • RE: Oracle DATE data format conversion..

    <C.M> Motta's question about dates and oracle>
    Dealing with dates and Oracle is somewhat of a nuisance. Oracle is very
    particular about how date strings are formatted, and if you get it wrong,
    you get the (unhelpful) message that C.M. Motta showed us. However, if
    you pass a DateTimeData to Oracle, Forte' does the right formatting for you.
    If you do need to format the date prior to interacting with Oracle, use the
    following format:
    dd-mmm-yy <time component>
    You can change the default format, but it is not easy.
    If you customise Express generated code that interacts with an Oracle
    database, again, make sure that you pass a DateTimeData, and not the
    .TextValue.
    Good luck!
    Richard Kirk

    Date: Wed, 06 Nov 1996 08:18:37 -0500
    To: "C. M. Motta" <[email protected]>
    From: Jim Milbery <[email protected]>
    Subject: Re: Oracle DATE data format conversion..
    Cc: [email protected]
    Cheers:
    Most likely what is happening is that you are using the default date
    format of Oracle, and you are sending a four-character year. As follows:
    SQL> insert into jimbo values ('01-dec-1997')
    2 /
    insert into jimbo values ('01-dec-1997')
    ERROR at line 1:
    ORA-01830: date format picture ends before converting entire inputstring
    >
    Oracle defaults to a format of 'dd-MON-yy'
    You can either truncate the year, or manipulate the date to match the standard
    database as follows:
    insert into jimbo values (to_Date('01-jan-1997', 'DD-MON-YYYY'))
    \jimbo
    At 09:21 AM 11/6/96 -0200, you wrote:
    Forte Users,
    First, Id like to thank all those who answered my question on
    droplist & SQL. I got just what I was looking for: its up and runnunig
    now.
    I have another question: Im trying to insert a DATE into an Oracle
    database. The source date is:
    data : DateTimeData = new;
    data.SetCurrent();
    So, when I try to insert data.Value or data.textvalue into DB, I
    get the following exception:
    ORA-01830: date format picture ends before converting entire
    input string.
    Are there any suggestions?
    Thanks for your help,
    C.M. Motta
    ====================================================================
    Jim Milbery
    Milbery Consulting Group
    132 N. West St., Allentown, PA 18102
    O: 610 - 432 - 5350 F: 610 - 432 - 5380
    E-Mail : [email protected]
    ====================================================================

  • Regarding Date Format Conversion

    Hi,
    In my project i am picking the date from the date picker which is a javascript program . Then i am displaying it on a jsp page .It is coming in mm/dd/yyyy format .I have to change it to dd/mm/yyyy format .
    I have the code for date formatting conversion .
    What my doubt is whether  the code should be written inside the jsp page or in the javascript .
    Thanks .

    Hi
    <%@page language="java" import="java.sql.*,java.util.*,java.text.*" %>
    <%SimpleDateFormat sdf= new SimpleDateFormat(dd/mm/yyyy );%>
    <% java.util.Date temp_date = sdf.parse(PassYourDateHere); %>
    use this with your jsp
    Regards
    Abhijith YS

  • Passing values to subreport in SSRS throwing an error - Data Retrieval failed for the report, please check the log for more details.

    Hi,
    I have the subreport calling from the main report. The subreport is based on MDX query agianst the SSAS cube. some dimensions in cube has values 0 and 1.
    when I try to pass '0' to the sub report as the parameter value, it gives an error "Data Retrieval failed for the report, please check the log for more details".
    Actually I am using table for storing these parameter values. In the main report I am calling this table (dataset) and passing these values to subreport.
    so I have given like [0],[1] and this works fine. when I give only either [0] or [1] then it is throwing an error.
    Could you please advise on this.
    Appreciate all and any help.
    Thanks,
    Divya

    Hi Divya,
    Based on the current description, I understand that there is no issue if you pass two values from main report to subreport, while the issue occurs when passing one value to subreport.
    To narrow down the issue, I want to confirm whether the subreport can run if there is only [0] or [1] in the subreport. If so, it indicates the query statements exist error in the subreport. If it’s not the case, this shows the issue occurs during passing
    values from main report to subreport. To make further analysis, please post the details of query statements of the subreport to the forum.
    Regards,
    Heidi Duan
    Heidi Duan
    TechNet Community Support

  • Can someone suggest some good books for sql reporting services (SSRS) 2012 or above?

    Hi Everyone,
        Can someone suggest some good books for sql reporting services (SSRS) 2012 and above? I ave been working on ssrs for past 2 months and have a basic understanding of ssrs.
    Regards
    Regards

    Hi,
    you can look for below options;
    http://www.amazon.in/Microsoft-Server-Reporting-Services-Recipes/dp/0470563117#reader_0470563117
    http://www.goodreads.com/book/show/18147604-learning-sql-server-reporting-services-2012
    Thanks
    Please Mark This As Answer or vote for Helpful Post if this helps you to solve your question/problem. http://techequation.com

  • Implicit date format conversion of report column

    Hello,
    The following expression defines date format for report column implicitly and doesn't reflect FSP_LANGUAGE_PREFERENCE with language independent format mask of the column attribute anymore:
    decode(end_date, to_date('31.12.2047', 'dd.mm.yyyy'), null, end_date) closed
    end_date is of TIMESTAMP(0) WITH LOCAL TIME ZONE type, format mask of the column attribute: DS TS
    Is it expected behavior?
    Thanks

    Edward Shevtsov wrote:
    Hello,
    The following expression defines date format for report column implicitly and doesn't reflect FSP_LANGUAGE_PREFERENCE with language independent format mask of the column attribute anymore:
    decode(end_date, to_date('31.12.2047', 'dd.mm.yyyy'), null, end_date) closed
    end_date is of TIMESTAMP(0) WITH LOCAL TIME ZONE type, format mask of the column attribute: DS TS
    Is it expected behavior?
    ThanksThe reason might be that you compare different datatypes in the SQL statement. The output of decode depends on those parameters.
    You can cast the column to a specific datatype or you make sure that your wanted datatype is used during the decode.
    example
    decode(end_date, to_timestamp_tz('31.12.2047', 'dd.mm.yyyy'), null, end_date) closed
    or
    cast(decode(end_date, to_date('31.12.2047', 'dd.mm.yyyy'), null, end_date) as timestamp(0) with local time zone) closed

  • Date format conversion in PL/SQL

    Hi,
    am new to pl/sql can any one please tel me how to wright a function to convert date format.
    I have date in database with different formats, the data type of the date in database is 'VARCHAR'. I want to convert the date format to standard format say 'DD-MON-YYYY'.
    In database i have different formats of date like 'dd-mon-yyyy',dd/mm/yyyy,dd.mm.yyyy,dd.mm.yy,MON DD,YYYY etc with some other formats also..
    Please tel me how to wright a function in pl/sql to convert date in to standard format.
    Thanks in advance.

    Ooops, which idiot stored dates as strings? That was silly.
    You'll have to aim to recognise each format... e.g.
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 1 as id, '01/02/2008' as dt from dual union all
      2             select 2, '14.07.2007' from dual union all
      3             select 3, 'APR-21-2007' from dual union all
      4             select 4, 'NONSENSE' from dual)
      5  -- END OF TEST DATA
      6  select id,
      7         CASE WHEN regexp_like(substr(dt,3,1), '[\.,\/]') THEN
      8              CASE WHEN length(dt) = 8 THEN
      9                TO_DATE(dt, 'DD/MM/YY')
    10              ELSE
    11                TO_DATE(dt, 'DD/MM/YYYY')
    12              END
    13              WHEN regexp_like(dt, '^([[:alpha:]]){3}-') THEN
    14                TO_DATE(dt, 'MON/DD/YYYY')
    15         ELSE
    16           NULL
    17         END as date_dt
    18* FROM t
    SQL> /
            ID DATE_DT
             1 01/02/2008 00:00:00
             2 14/07/2007 00:00:00
             3 21/04/2007 00:00:00
             4You're problem will come if you actually have dates stored as both DD/MM/YYYY and MM/DD/YYYY type formats because then you won't know if e.g.
    01/02/2007
    is
    1st Feb 2007 or 2nd Jan 2007

  • Problem with date format conversion

    Hi All,
    I was trying to load from a flat-file to an ods through psa. the file has a date format which is mm/dd/yyyy. i want to convert that to yyyymmdd. i created a custom object ZDAT for this field of type char with length 10. i wrote a code in transfer routine for the conversion as follows:
    DATA : ZT1 LIKE SYST-DATUM,
    STR1 TYPE STRING,
    STR2 TYPE STRING,
    STR3 TYPE STRING.
    SPLIT TRAN_STRUCTURE-/BIC/ZDAT AT '/'
    INTO STR1 STR2 STR3.
    CONCATENATE STR3 STR1 STR2 INTO ZT1.
    RESULT = ZT1.
    it reported error in PSA records while loading aS " Infoobject /BIC/ZDAT does not contain alpa-conforming value 20050321.
    P.s: for this record i was abt to load 03/21/2005 to zdat.
    thanks,
    anitha.

    hi anitha!
       ok!
      in the transferrules you use the ZDAT as an field for date in transferstructure. but in info source use the 0calday.
    so now
        you need to write your routine in the transfer rules for 0calday which can be derived from zdat which can be derived from the zdat.
    so your Transfer structure will be same as
       zmid, zmatgrp, zdat, zcid, zloc, zqty
    But your Info source must be like
       zmid, zmatgrp, 0calday, zcid, zloc, zqty
    and in transfer rule i suggest you to use the following code for the 0calday.
        DATA : ZT1 LIKE SYST-DATUM,
         STR1 TYPE char(2),
         STR2 TYPE char(2),
         STR3 TYPE char(4).
         SPLIT TRAN_STRUCTURE-/BIC/ZDAT AT '/'
         INTO STR1 STR2 STR3.
         CONCATENATE STR3 STR1 STR2 INTO ZT1.
         RESULT = ZT1.
    hope it makes things clear....
    with regards
    ashwin
    Message was edited by: Ashwin Kumar Gadi

  • Date Format Problem in Custom Report

    Dear all ,
    I am generating SQL statement for the report , i am passing (param_date from ) and (param_date to) to get data from SITs , and there is tow segments in the SITs : (SIT_date from ) and (SIT_date to) also ,, getting the data from the SITs by comparing the dates for the SIT and the parameters ,,, i am facing problem in the date format , ,, could any one please help me what is the format that i can compare the between dates in the SIT and the Parameters ???
    Best Regards
    Edited by: user6781803 on Jan 3, 2010 7:28 AM

    >
    ... i am facing problem in the date format ...
    >
    What is the problem ? Pl also post full versions of your OS and EBS.
    HTH
    Srini

  • Date format conversation in OBIEE

    Hello guys
    I am a quick question about how to stop OBIEE from using to_date conversation? The date format in the db is dd/month/yy, and when I run any report in OBIEE answer using Date columns, it will always convert the format to "dd/mm/YYYY". The sql generated will always have a to_date() in where clause..
    Is there a way to not have OBIEE does that and just show the date with format as it is and drop the to_date conversion in SQL?
    Thanks

    I think you are getting confused here. Oracle's default date format is dd-mon-yyyy. So when you run a query like this:
    DATE_COLUMN = '01-Nov-2009'
    Oracle applies an IMPLICIT data type conversion to your date string and converts it to a date data type. Whether you allow Oracle to do the implicit conversion or do it explicitly like this DATE_COLUMN = To_date('01-Nov-2009', 'dd-mon-yyyy') should always result in the same query performance. When to TO_DATE functions affect query performance? When you apply the function over the DATE_COLUMN like this:
    TO_DATE(DATE_COLUMN, 'dd-mon-yyyy') = '01-Nov-2009'
    Why? Because indexes on DATE_COLUMN WILL NOT be used unless you have defined a function level index with a index column using the function: TO_DATE(DATE_COLUMN, 'dd-mon-yyyy'). My guess is that your DATE_COLUMN is not a date but a varchar2, therefore when you pass in To_date('01-Nov-2009', 'dd-mon-yyyy') Oracle does an IMPLICIT conversion of your DATE_COLUMN to DATE data type to match the data type of your where condition hence it is taking long to execute as no indexes are used. Can you confirm what is the exact data type of the DATE_COLUMN you are using to filter on? Do you have an index defined in that column? Can you confirm exactly how is the index is defined? Have you ran statistics on the table AND the indexes as well?

  • How to get period date of for a given month from a given date in mdx for SSRS report (mm/dd/yyyy)

    I have a situation,  where i need to write expression Period to date(PTD). i want to know how to get the period date. i want you to help in writing Period date or else is there any function to get period date for a given date(the  date is given
    from the parameter dynamically) in MDX for SSRS report
    ram

    Hi ram,
    Per my understanding that you want to get the period date based on the month selected and the given date, right?
    Could you please provide details information below to help us better understanding your requirements, thus we will be more effective to provide an solution:
    What is the format of the period date you want to get, is this date in the DB and you want to filter it based on the month and the given Date?
    Did the month and given date are two parameters in the report? if possible, could you please provide some sample data in the DB and also the snapshot of the report structure
    I assume you want to get the period date(mm/dd/yyy) between the select month(e.g:Feb) and the given date (10/1/2014) and you should get the date between(02/01/2014-10/1/2014).
    If so,and you also have two parameter "Month","EndDate"(EndDate is the given date), please reference to details information below:
    You can create an new parameter "BeginDate" (Date/Time) which is the begin date of the period, you can use the expression to get the value based on the value of the month and the year value from the given date,finally hide this parameter:
    Specify the available value:
    Label:=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value)
    Value:=CDate(=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value))
    Specify the default Value:
    Value:=CDate(=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value))
    Add filter to the dataset as below:
    Preview you will get all the date in the given Period:
    If you still have any problem, please feel free to ask.
    Regards
    Vicky Liu

  • Displaying data in a pl/sql report

    Hi,
    If the regional settings of the system is german(germany) and if I try to display a procedure output as a report written in pl/sql in .xls format I am getting wrong data displayed.
    Ex: If the duration in hours is 5.5 it displays as 05. Mai. Actually i want it to be dispalyed as 5.5 in the .xls file.
    Please help me in this regard.
    Thanks in advance

    This is a typical (German) Excel problem. Excel is converting your values to a date because the German date format mask fits to the German number NLS settings.
    There are some solutions to the problem but non is really simple.
    1) Create a CSV like file, but do not name it CSV. E.g. Spooloutput.dat with delimiter = '|'. Import this as a text file in excel and use the delimiter.
    2) Change your excel settings: "Extras/Optionen/International/Trennzeichen fom Betriebssystem übernehmen" => uncheck this option and choose other chars. Write your number data with those chars.
    3) Create an Excel-Readable XML where the column type is supplied. My favourite, but I didn't do it so far.

  • How to compare two tables data...need sql report or utility to find differe

    Hi,
    We have a requirement where we are asked to find data differences between two tables and one of the tables reside on remote database. The database version is same ( 10g ) and datatypes for the tables are similar.
    The client is looking for a sql report or kind of utility to display the data differences for each column ( if possible count differences ) with some meaningful error messages.
    Could anyone let me know the best possible way of doing it..?
    Thanks
    Hitarth

    Hi,
    I found something for tables comparison but getting one error...can you check this please and let me know what is wrong
    Here is the function:
    CREATE OR REPLACE FUNCTION compare_query_results (
    p_query1 IN VARCHAR2
    , p_query2 IN VARCHAR2
    , p_raise_error_if_not_equal IN BOOLEAN DEFAULT FALSE
    , p_raise_error_if_no_rows IN BOOLEAN DEFAULT FALSE
    RETURN NUMBER
    IS
    -- Constants
    c_query_results_equal CONSTANT PLS_INTEGER := 0;
    c_query_results_not_equal CONSTANT PLS_INTEGER := 1;
    oracr CONSTANT VARCHAR2 (1) := CHR (10);
    -- Variable Declaration
    v_sql_stmt VARCHAR2 (32767);
    v_record_count PLS_INTEGER;
    v_return_code PLS_INTEGER;
    v_record DUAL.dummy%TYPE;
    v_result_set_has_rows BOOLEAN;
    -- Ref Cursors
    v_cursor sys_refcursor;
    -- Custom Defined-Exceptions
    result_sets_do_not_match EXCEPTION;
    query_returns_no_rows EXCEPTION;
    BEGIN
    -- Get the count of differing records between p_query1 and p_query2
    dbms_output.put_line('Start-1');
    v_sql_stmt :=
    ' (SELECT /*+ materialize */'
    || SUBSTR (p_query1, INSTR (UPPER (p_query1)
    , 'SELECT'
    , 1
    , 1
    ) + 6)
    || ')
    , (SELECT /*+ materialize */'
    || SUBSTR (p_query2, INSTR (UPPER (p_query2)
    , 'SELECT'
    , 1
    , 1
    ) + 6)
    || ')
    SELECT ''X''
    FROM (
    (SELECT * FROM test1 MINUS SELECT * FROM test2)
    UNION ALL
    (SELECT * FROM test2 MINUS SELECT * FROM test1)
    dbms_output.put_line('Start-2');
    OPEN v_cursor
    FOR v_sql_stmt;
    dbms_output.put_line('Start-3');
    FETCH v_cursor
    INTO v_record;
    dbms_output.put_line('Start-4');
    v_result_set_has_rows := v_cursor%FOUND;
    dbms_output.put_line('Start-5');
    CLOSE v_cursor;
    dbms_output.put_line('Start-6');
    -- If there are rows - the result sets do NOT match...
    IF v_result_set_has_rows
    THEN
    v_return_code := c_query_results_not_equal;
    IF p_raise_error_if_not_equal
    THEN
    RAISE result_sets_do_not_match;
    END IF;
    -- If there are no rows - the result sets do match...
    ELSIF NOT v_result_set_has_rows
    THEN
    IF p_raise_error_if_no_rows
    THEN
    -- Check to make sure that the queries contain rows if desired...
    v_sql_stmt := 'SELECT ''X''
    FROM (' || oracr || p_query1 || oracr || ')';
    OPEN v_cursor
    FOR v_sql_stmt;
    FETCH v_cursor
    INTO v_record;
    IF v_cursor%NOTFOUND
    THEN
    CLOSE v_cursor;
    RAISE query_returns_no_rows;
    END IF;
    CLOSE v_cursor;
    END IF;
    v_return_code := c_query_results_equal;
    END IF;
    RETURN v_return_code;
    EXCEPTION
    WHEN result_sets_do_not_match
    THEN
    raise_application_error (-20101, 'The Queries'' result sets do NOT match. Error returned
    as requested.');
    WHEN query_returns_no_rows
    THEN
    raise_application_error (-20102, 'The Queries'' result sets match, however they contain no
    rows. Error returned as requested.');
    WHEN OTHERS
    THEN
    -- Raise the error
    raise_application_error (-20103
    , 'There is a syntax or semantical error in one or both queries
    preventing comparison.'
    || oracr
    || 'Error Stack :'
    || oracr
    || DBMS_UTILITY.format_error_stack ()
    || oracr
    || 'Error_Backtrace:'
    || oracr
    || DBMS_UTILITY.format_error_backtrace ());
    END compare_query_results;
    I have created two tables ( test1 and test2 ) with few columns and with the same datatypes and executed the above function...I am getting error as folliowing:
    DECLARE
    ERROR at line 1:
    ORA-20103: There is a syntax or semantical error in one or both queries
    preventing comparison.
    Error Stack :
    ORA-00900: invalid SQL statement
    Error_Backtrace:
    ORA-06512: at "ORAOWNER.COMPARE_QUERY_RESULTS", line 53
    ORA-06512: at "ORAOWNER.COMPARE_QUERY_RESULTS", line 121
    ORA-06512: at line 12
    Could someone please help me fixing this error..It would be really appreciated
    Thanks
    Hitarth

  • Date Format Issue IN BEX REPORT

    Hi Experts,
    we are working on BW 3.5.
    we have a ODS where data is uploaded through flat file and there are 5 to 7 date field all made of Z infoobjects.
    So now the user is putting the data for these Date fields as 20110901 = 1st sep2011. but in report its coming as 09/01/2011
    when i checked all the Z fields that are created for this date fields have reference character as Date
    only one field is character so it is coming correct as given by the user
    but rest all are appearing in different format . In ODS also the date is coming as 09/01/2011
    now the user want all the data to be in the same format as given by HIM.
    I cant even change the properties of these Z info object removing the reference info object 0Date and make them character string.
    so now please suggest how to upload the date given by the user as it is without changing the format and also how to change the format for the back data as its flat file so No data can be deleted.
    thankkkkkkkks

    hello
    Bex analyzer is an excel add-in. Date formats are based on your regional settings.
    If you want to have a different date format in the sap gui then you have to change your user profile in sap system.
    Flat file upload needs the date format in a database format (YYYYMMDD).
    You can transform the date in the transformation step with rules or with a routine( abap coding).
    Thank you
    Yiannis

  • Date format interfering with interactive report

    My APEX version is 3.1.1.00.09.
    I'm using a method described elsewhere to change the global date format of my application. I have application items for a start and end date. I have two application processes, one for On Load: Before Header, the other for On Submit: After Page Submission - Before Computations and Validations. They both do:
    DBMS_SESSION.SET_NLS(param => 'NLS_DATE_FORMAT', value => '''fmMM/DD/fmYY''')
    Okay, all is well with that, my dates seem to stay the way I want them to. Since our upgrade I'm going through each section of my application and updating as necessary, and I particularly want to use the interactive reports. They work fine when the page is loaded, but if I change any options on the interactive report and submit it, I get an "ORA-01843: not a valid month" error. If I refresh the page, everything works as it should.
    What can I do to get around this, or do I have something wrong with my method that is causing this to happen?
    Chris

    Hi Chris,
    I tried to replicate this, but could not. Now granted, I tried this using the new "modern" method of controlling the default application date format via the new application Globalization attribute "Application Date Format". I set the Application Date Format to fmMM/DD/fmYY and my IR on EMP worked just fine.
    If you can replicate this on apex.oracle.com (using Application Date Format), I'd be happy to take a look at it.
    Joel

Maybe you are looking for

  • Item Category determination based on Order Reason

    Hi experts, There is a requirement where for a particular sale order type ( ZSC in this case ), there are 6 types of order reasons available. And depending upon the order reason chosen, the corresponding item category needs to be determined automatic

  • Live Type Background Issue

    good afternoon, I am using Live type to create text and I want to place it and some images over a background. I have created a file in Live type, selected a background, added a company logo and have been able to view my project with Live type as I wa

  • How to find description for the bugs fixed in a CPU ( Critical patch alert)

    Hi I am having a hell of a time trying to figure out WHICH BUGS are fixed in the recent Critical patch alert I looked into the README file of the patch ( in my case its 8534387 for Solaris SPARC ) - but even in the README file there is only the list

  • Unicode complaincy check for ABAP included in Start Routines

    Hi, we are planning to run unicode conversion for BW and we have tried to analyze our system with UCCHECK transaction to make sure that ABAP would be complaint with unicode. It's mentioned in documentation that this transaction is only capable of exe

  • Tolerances for HU physical inventory differences

    Tolerances customized in SPRO OMJ2 do not apply for HU physical inventory diferences generated by HUINV05 transaction. We need to implement tolerances on HU (Handling Units) physical inventories. So thank you for any help on the subject.