Results 1 to 2 of 2

Thread: To_date problem

  1. #1
    Contributing Member
    Join Date
    Mar 2008
    Answers
    66

    To_date problem

    Hello friends,

    SELECT DISTINCT DSL_STK_DATE FROM DSL_STOCK_LEDGER
    The output of the above command is
    DSL_STK_DATE
    28-02-2008
    29-02-2008
    01-03-2008
    02-03-2008
    03-03-2008

    But the following command displaying unexpected result for the same column. It is showing year portion as 0008. What might be the cause?
    SELECT DISTINCT TO_DATE(DSL_STK_DATE, 'DD-MM-YYYY') DSL_STK_DATE FROM DSL_STOCK_LEDGER
    DSL_STK_DATE
    28-02-0008
    29-02-0008
    01-03-0008
    02-03-0008
    03-03-0008

    Regards
    Babi


  2. #2
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    Re: To_date problem

    DSL_STK_DATE is date datatype then no need to use to_date function againg.u still need to use to_date then u need to alter the session using

    alter session set nls_date_format = 'dd-mm-yyyy'
    SELECT DISTINCT TO_DATE(DSL_STK_DATE, 'DD-MM-YYYY') DSL_STK_DATE FROM DSL_STOCK_LEDGER

    other wise use
    SELECT DISTINCT TO_char(DSL_STK_DATE, 'DD-MM-YYYY') DSL_STK_DATE FROM DSL_STOCK_LEDGER
    or
    SELECT DISTINCT TO_DATE(DSL_STK_DATE, 'DD-MM-RRRR') DSL_STK_DATE FROM DSL_STOCK_LEDGER
    if u use RRRR in place of yyyy u need to note some points

    Accepts a 2-digit year and returns a 4-digit year.
    A value between 0-49 will return a 20xx year.
    A value between 50-99 will return a 19xx year.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact