Home Forums SQL Server 2008 Working with Oracle Convert date format in SQL sever report(BIDS) with Oracle date format RE: Convert date format in SQL sever report(BIDS) with Oracle date format

  • I'm assuming the target database is Oracle and that the datatype of mytable.date is DATE.

    If this is the case you have two options, option #1 is to write a stored procedure that accepts the two parameters; option #2 is to send the parameters alongside your query which arguable defeats the purpose(*).

    Having said that, code below shows how to use bind-variables in your Oracle sql code.

    VARIABLE STARTDATE VARCHAR2(11)

    EXEC :STARTDATE := '01-JAN-2012'

    VARIABLE ENDDATE VARCHAR2(11)

    EXEC :ENDDATE := '10-JAN-2012'

    SELECT *

    FROM MYTABLE

    WHERE MYTABLE.DATE BETWEEN TO_DATE(:STARTDATE, 'dd-mon-yyyy')

    AND TO_DATE(:ENDDATE, 'dd-mon-yyyy')

    ;

    Hope this helps.

    (*) exception would be a really well organized environment where no literals are allowed on queries.

    _____________________________________
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at Amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.