Behaviour of to_char function in sqlplus versions 8.1.6.0.0 and 9.0.1.3.0 .

Behavior of to_char function in sqlplus versions 8.1.6.0.0 and 9.0.1.3.0:
Hello,
We are migrating our apps between different environments and we observed the following behaviour:
When using the command select to_char(sysdate,'D') from dual, this gives out a value of 4 in sqlplus version 8.1.6.0.0 (win NT). The same command gives out a value of 3 in sqlplus version 9.0.1.3.0 (win XP).
The underlying software is Oracle Enterprise Edition Release 8.1.7.4.0 in both the cases. Why this difference in behaviour? Can anyone please advise me.
regards,
Srikanth

The first day of week depends on the globalization parameter NLS_TERRITORY. Set it for the instance or for the session to AMERICA to get the week start on sunday. You can also set this in the NLS_LANG os variable (export NLS_LANG=american_germany.we8iso8859p1)
SQL> alter session set nls_territory='germany'
SQL> select to_char(sysdate, 'Day D') from dual;
TO_CHAR(SYS
Wednesday 3
SQL> alter session set nls_territory='america';
SQL> select to_char(sysdate, 'Day D') from dual;
TO_CHAR(SYS
Wednesday 4Kind regards
Laurent Schneider
OCM-DBA

Similar Messages

  • TO_CHAR FUNCTION IN ORACLE FORM

    HI,
    Table called A has column name col1
    col1
    12563.563
    52685.563
    05263.540
    I would like to use SUBSTR(col1,2,6) for insert values from A table to B table by Oracle form and following values are inserted in B table
    2563.5
    2685.5
    263.4
    If I use SQLPLUS it is inserting as my requirement like
    2563.5
    2685.5
    5263.4
    Third row should be 5263.5 instead of 263.4. In Oracle form may have internal coversion function to convert character value to number values, I do not want to convert the value to number. Both table columns are varchar2 column.
    What is the equal to_char function in Oracle form. If it is NLS_NUMERIC_CHARACTERS, please what are the parameters to be passed along with column.
    Thanks in advance
    Saravanan.

    Hello,
    If you don't want to take account any calculation on the decimal part, you could consider the Trunc() function instead of the To_Char():
    Connected to:
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    SQL> select to_char(52685.563,'00000000.0'), trunc(52685.563,1) from dual
      2  /
    TO_CHAR(526 TRUNC(52685.563,1)
    00052685.6            52685.5
    SQL> Francois

  • Reg: error while converting a date datatype to the char using TO_CHAR function.

    Hello all,
    I'm trying to convert a date datatype to the specified format (i.e., by using vaariable using the to_char function in my sql,
    SQL:
    select 0 dummy,'select' from dual
    union all
    select a.COLUMN_ID dummy,
    (case a.DATA_TYPE when 'NUMBER' then '''''' || '||' || a.COLUMN_NAME || '||'',''||'
                      when 'DATE' then '''"''' || '||' || TO_CHAR(a.COLUMN_NAME,'&dateformat') || '||' || '''",''' || '||'
                      else '''"''' || '||' || a.COLUMN_NAME || '||' || '''",''' || '||'
                end)
    from DBA_TAB_COLUMNS a
    where a.OWNER = upper('&owner_name')
    and a.TABLE_NAME = upper('&table_name')
    union all
    select 998 dummy,''' ''' from dual
    union all
    select 999 dummy,'from &owner_name..&table_name;' from dual
    order by dummy
    error:
                      when 'DATE' then '''"''' || '||' || TO_CHAR(a.COLUMN_NAME,'DD-MM-YYYY') || '||' || '''",''' || '||'
    ERROR at line 5:
    ORA-01722: invalid number
    Please help me in resolving this, Thanks in advance.
    Regards,
    Konda.

    > ISA Server is not configured to allow SSL requests from this port. Most Web browsers use port 443 for SSL requests. (12204)
    This seems to be your specific network configuration.  It seems that your corporate network is blocking HTTPS requests which don't use port 443. Your ABAP system is configured to use a port other than 443. Either talk to your basis admins about changing your ABAP system configuration to use port 443 or talk to your network administrators to allow whichever port the ABAP system is running on.

  • Need help in to_char function

    Hi All,
    I'm using below sql query to get sysdate with time stamp.
    select to_char(sysdate,'YYYYMMDD HH24:MM:SS') from dual
    This gives me below result:  20130816 05:08:49
    Strangely, when I keep on running the same query, I notice after 60 seconds are complete, time stamp starts with  20130816 05:08:01 again.
    Am i missing something here..
    Thanks in advance

    Karthick_Arp wrote:
    Keep a simple thing in mind. Date stored in the DB does not have any format. Format need to be applied while you display. The default date format is specified by the NLS_DATE_FORMAT parameter. You have used TO_CHAR to display date in a specific format. But the problem is that you have converted DATE into string. So if its just for display purpose then set the NLS_DATE_FORMAT, do not use TO_CHAR.
    With respect to your issue You need to represent Minute as MI. You have represented it as MM (Month) That's why you see 08 always.
    " the problem is that you have converted DATE into string"
    No, the problem was that he was explicitly using an incorrect format mask, specifying months where he should have specified minutes.
    The problem inherently cannot be the result of converting a DATE into a string.  Dates are always converted to strings for presentation, either implicitly by using the controlling setting of NLS_DATE_FORMAT (which can be set at several levels) or explicitly by using the to_char function.  Oracle will always convert.  It has to.  Internally, a date is binary gibberish.  But computer screens and printers can only show strings of characters, so the DATE will be converted to a character string, by hook or by crook.  And the method of oracle making that conversion is exactly the same.  The only thing that varies is how the user chooses to make that specification.  And "not choosing" (by not using the to_char function) is still choosing ... choosing to rely on nls_date_format.

  • To_char function help

    Hi All,
    I have run this query in my oracle database
    SELECT
    J.NAME,
    (CASE J.STATUS WHEN 'Completed' THEN COUNT(J.STATUS) ELSE 0 END) CURRENT_MONTH_COMPLETE,
    (CASE J.STATUS WHEN 'Pending for Process Engine' THEN COUNT(J.STATUS) ELSE 0 END) CURRENT_MONTH_IN_PROGRESS
    FROM
    CMN_SCH_JOBS_V J
    WHERE
    J.STATUS IN ('Completed','Pending for Process Engine') AND J.LANGUAGE_CODE='en'
    and to_char(J.START_DATE,MM')=12
    GROUP BY J.NAME,J.STATUS;I have a doubt regarding this
    to_char(J.START_DATE,MM')=12Basically to_char() function returns a string value, but when it is equated against a numeric value oracle should raise an error right, this query is running fine. Please tell why this is happening.
    Regards
    Praveen Vuppalapati

    What a strange query. I'd expect it to be either:
    SELECT
    J.NAME,
    J.STATUS
    COUNT(*)
    FROM
    CMN_SCH_JOBS_V J
    WHERE
    J.STATUS IN ('Completed','Pending for Process Engine') AND J.LANGUAGE_CODE='en'
    and to_char(J.START_DATE,MM')=12
    GROUP BY J.NAME,J.STATUS;... or ...
    SELECT
    J.NAME,
    SUM(CASE J.STATUS WHEN 'Completed' THEN 1 ELSE 0 END) CURRENT_MONTH_COMPLETE,
    SUM(CASE J.STATUS WHEN 'Pending for Process Engine' THEN 1 ELSE 0 END) CURRENT_MONTH_IN_PROGRESS
    FROM
    CMN_SCH_JOBS_V J
    WHERE
    J.STATUS IN ('Completed','Pending for Process Engine') AND J.LANGUAGE_CODE='en'
    and to_char(J.START_DATE,'MM')=12
    GROUP BY J.NAME;Ought to wrap the to_char() in a to_number as well, really.

  • Planning function to copy  version A of year 2007 to Version B of 2008 - IP

    I have a copy planning function which has a variable on from version and to version and it works fine.I can copy.So version to version for the same year works fine.
               Another requirement is to copy Version A of year 2007 to version B of year 2008.For this in the planning function I made version,year and calyearmonth all 3 as changeable and have variables on from version from year and to version and to year.I don't have a variable on calyearmonth.
              I run the query for version B and year 2008 and CALYEARMONTH 1/2008-12/2008 and it returns empty results as there is no data for version B for year 2008.then I execute the planning function to copy data from version A and year 2007 to version B and year 2008.I am getting the following error "CalyearMonth is not included in selection".I ran the query for 1/2008 - 12/2008.I didn't understand this.
            In the planning function filter I don't have any filter for calyear and calyear month.But it is there in the query.
    Thanks

    Hi Siva,
    Since you do not have the calmonth as the change characteristic in your plannning function.The values would be copied to year 2008 with month as #.
    So there would be no values for months of 2008 and hence you are getting that error.
    You need to copy the month figures also for data to be seen in the report.
    Assign points if useful.
    Ajay

  • What is the use of To_date, to_char functions?

    what is the use of To_date, to_char functions?
    while i am using these in my day to day activities but never able to know the exact working of tehse.
    Message was edited by:
    437022

    Dates are stored and manipulated as coded (binary) values that always contain "century, year, month, date, hour, minute second"
    We don't want to see the date as stored. We want to see the characters (digits) that make up the date. So we use to_char(the-date-value)
    We want to tell the system a date, but have a heck of a time entering the binary. So we input the characters (digits) that make up the date and tell the system to convert that to a binary 'date' using to_date(our-string-that-respresents-dates)
    The magic Oracle has added is the format codes (see chapter 2 of the SQL Reference manual for the complete list). We can get the system to print out dates and times, including day of week (and so on) using format codes.
    The default format is to show us the date but not the time. Which leads a lot of people to believe that the time is not stored.

  • I have bought English verion In Design. I need the function of Chinese version. How can I converse it? Thanks

    I have bought English verion In Design. I need the function of Chinese version. How can I converse it? Thanks

    Ah.   I understand now.   I suspect it is the technical problem that the money keeps the account alive.
    Go to  http://www.apple.com/support/itunes/contact/  - and click on Express lane followed by iTunes > iTunes store.   Explain to them and see if they will help you raise a new account.
    Remember, your account and means of payment must relate to the country you permanently reside in.

  • Error in result of To_Char function.

    Hi,
    My name is Ramanujulu, I was practicing Date functions and found one error in one of the To_Char functions.
    Please assume the sysdate as 19th Decmber 2006. (I used this date in example)
    SQL> select to_char(sysdate-7, 'ddspth-month-syear') from dual;
    TO_CHAR(SYSDATE-7,'DDSPTH-MONTH-SYEAR')
    twelfth-december - two thousand six
    It returns the 12th as twelfth. (Additional letter F). Who will correct this and how do i make this change in my Database.
    Please let me know how to correct this.
    Thanks,
    Ramanujulu B.

    http://dictionary.reference.com/browse/twelfth

  • Trouble getting a timestamp formatted by a 'to_char' function

    We have trouble getting a timestamp formatted by a 'to_char' function and a 'group by'
    for a count. By assigning the result of the to_char function to an attribute and
    grouping on that attribute, we try to get the frequency of an event.
    What happens is a non predictable 'IllegalArgumentException' on
    'Timestamp.class' while getting the timestampvalue.
    We make use of a scrollablecursor as you can see in the stacktrace.
    java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffff
    at java.sql.Timestamp.valueOf(Timestamp.java:160)
    at oracle.sql.CHAR.timestampValue(CHAR.java:567)
    at oracle.jdbc.driver.ScrollableResultSet.getTimestamp(ScrollableResultSet.java:658)
    at oracle.toplink.oraclespecific.Oracle9Platform.getObjectFromResultSet(Unknown Source)
    at oracle.toplink.internal.databaseaccess.DatabaseAccessor.getObject(Unknown Source)
    at oracle.toplink.internal.databaseaccess.DatabaseAccessor.fetchRow(Unknown Source)
    at oracle.toplink.internal.databaseaccess.DatabaseAccessor.cursorRetrieveNextRow(Unknown Source)
    at oracle.toplink.queryframework.ScrollableCursor.retrieveNextObject(ScrollableCursor.java:512)
    at oracle.toplink.queryframework.ScrollableCursor.loadNext(ScrollableCursor.java:357)
    at oracle.toplink.queryframework.ScrollableCursor.hasNext(ScrollableCursor.java:233)
    After restarting the application server there is a chance that the query returns
    with the expected results. But most of the times it just returns the above
    mentioned exception.
    I don't see the logic in the apparently random parsing of the value.
    The column in the database is a timestamp, but that the reason why i'm using the
    to_char method.

    This is a bug in TopLink with ReportQuery. Please report this is Oracle technical support. Basically TopLink is converting to the attribute type, but should not be if a function was applied to the expression.
    To workaround the issue you can use getField(/) in the expression instead of get(/) (using the database field name instead of the class attribute name).

  • Unusual result with TO_CHAR function on a date

    Can anybody explain to me why I see two different results if I use the following SQL in PL/SQL Developer (Oracle Database 10g Enterprise Edition Release 10.2.0.1.0)? I'm not sure if I have a wrong setting in Oracle or PL/SQL Developer, or if I'm just misunderstanding how the TO_CHAR function works. Many thanks.
    select sysdate, to_char(sysdate, 'dd/mm/yyyy hh:mm:ss') as FORMATTED_DATE from dual
    Results:
    SYSDATE
    10/02/2009 16:52:32
    FORMATTED_DATE
    10/02/2009 04:02:32

    select sysdate, to_char(sysdate, 'dd/mm/yyyy hh:mm:ss') as FORMATTED_DATE from dual
    Results:
    SYSDATE
    10/02/2009 16:52:32
    FORMATTED_DATE
    10/02/2009 04:02:32It should not be -> mm it should be mi .
    Got me?
    Regards.
    Satyaki De.

  • TO_CHAR Function Format Argument Limit

    I was curious if there is a limitation to the length of the string used as the Format argument in the TO_CHAR Function? If so, how long is it?

    I couldn't find it in the documentation, but it appears at first glance to be 63 for numbers with a simple format mask. You could experiment with the others:-
    SQL>
    SQL> DECLARE
      2     v1 VARCHAR2(32767);
      3     v2 VARCHAR2(32767);
      4  BEGIN
      5     FOR i IN 1 .. 32767 LOOP
      6        BEGIN
      7           v1 := v1 || '9';
      8           SELECT TO_CHAR(1,v1) INTO v2 FROM dual;
      9        EXCEPTION
    10           WHEN OTHERS THEN
    11              DBMS_OUTPUT.PUT_LINE(
    12                 'Maximum length of format mask for ' ||
    13                 'numbers is [' || TO_CHAR(i-1) || ']'
    14                 );
    15              RETURN;
    16        END;
    17     END LOOP;
    18  END;
    19  /
    Maximum length of format mask for numbers is [63]
    PL/SQL procedure successfully completed.
    SQL> SELECT TO_CHAR(1, '99999999999999999999999999999999999999999999999999999999999999') as sixty_two
      2  FROM   dual;
    SIXTY_TWO
                                                                  1
    SQL> SELECT TO_CHAR(1, '999999999999999999999999999999999999999999999999999999999999999') as sixty_three FROM dual
      2  /
    SIXTY_THREE
                                                                   1
    SQL> SELECT TO_CHAR(1, '9999999999999999999999999999999999999999999999999999999999999999') as sixty_four FROM dual
      2  /
    SELECT TO_CHAR(1, '9999999999999999999999999999999999999999999999999999999999999999') as sixty_four FROM dual
    ERROR at line 1:
    ORA-01481: invalid number format modelRegards
    Adrian

  • Missing functionality in demo version

    I downloaded the demo version of Lightroom 1.0 (I'm waiting for my RawShooter email). My version of Lightroom lacks Split Toning and Lens Correction tabs in the Develop tab.
    I did a complete reinstallation, restarted my computer, but this did not solve the problem.
    Any ideas?
    Thanks, Steve

    There is no such thing as a "Demo Version". It is a full version with a thirty day time limit, unless you provide it a Serial Number, then it is yours to use forever! No difference it what it has by one iota!
    Don

  • To_char-function on number causes loss of leading zero

    Hello everybody,
    I need to ask a question about the to_char method. I have number-values, which occur in the format " xxxxx,x ", which means:
    - a not limited amount of leading digits
    - optional a decimal point
    - if a decimal point, then the numer has at most one digit afterwards
    It looks okay with every kind of number, just the 0,x looks strange.
    It is converted to " ,x ", e.g. 0,5 to ,5.
    How do I get a proper format?
    I used to_char(mynumber, 'FM90D9'), but it has always a decimal point and doesn't work for large numbers.
    Thanks in advance!

    Hi,
    As Ganesh said, it would really help if you posted a little sample data and the results you wanted from that data.
    For example, the data could be:
    CREATE TABLE     table_x
    (       num_col          NUMBER
    INSERT INTO table_x (num_col) VALUES (0);
    INSERT INTO table_x (num_col) VALUES (1/7);
    INSERT INTO table_x (num_col) VALUES (.5);
    INSERT INTO table_x (num_col) VALUES (1.6);
    INSERT INTO table_x (num_col) VALUES (9876543210);
    INSERT INTO table_x (num_col) VALUES (1);
    INSERT INTO table_x (num_col) VALUES (-2);
    INSERT INTO table_x (num_col) VALUES (3.004);And the results you want from that data might be:
    `  NUM_COL FMTD
            -2 -2
             0 0
    ,142857143 0,1
            ,5 0,5
             1 1
           1,6 1,6
         3,004 3
    9876543210 9876543210where num_col is the number in Oracle's default format, and fmtd is how you want it, which I assume is:
    (a) At most, 1 digit after the decimal marker
    (b) no decimal marker if it would cause the string to end in ',0'
    (c) at least one digit before the decimal marker (if there is a decimal marker)
    (d) any number of digits before the decimal marker. The query below actually has a limit of 40, which exceeds the accuracy of Oracle integers anyway.
    The query below produced the output above from the data above:
    ALTER SESSION         SET NLS_NUMERIC_CHARACTERS = ', ';
    SELECT     num_col
    ,        LTRIM ( REPLACE ( TO_CHAR ( num_col
                                    , '9999999999999999999999999999999999999990d0'
                          , ',0'
                 )          AS fmtd
    FROM      table_x
    ORDER BY  num_col
    ;

  • What is the correct way to use Version Informatio​n from the sequence and from the deployment tool

    I seem to be missing something in how the various version numbers are supposed to be used.    My end goal is to log and possibly display in the UI the version of the sequence and which installer version was used to inspect a UUT.   I have gotten most of the way there using:
     How Can I Programmatically Query the Sequence File Version of My TestStand Sequence? 
    and logging this into the report with a function which contains:
    Parameters.UUT.AdditionalData.SetValString("Test Version",1,RunState.SequenceFile.Data.Version),
    Parameters.UUT.AdditionalData.SetFlags("",0,PropFl​ags_IncludeInReport)
    The "Deployment Version" in the TestStand Deployment Utility auto incrementing the 3rd position of a version number  while the sequence auto increment is working on the 4th.   
    My first question is are these 2 version numbers in anyway supposed to be related to each other?   As it seems to me you would want those 2 reversed, I can make several installers based on sequence version X, making changes to what supporting files are also installed.
    If they are not related as I suspect that they are not.  How do I programatically grabed the installer version and also log that into the result report?   
    is there an option to perform a custom deployment build step to log the deployment version before it builds and then reference that log at runtime of the test?

    Hi,
    The sequence file version and deployment versions are not related.
    You can build the installer with whatever version you want using the command line :
    https://decibel.ni.com/content/docs/DOC-38947
    Hope this helps,
    Ravi

Maybe you are looking for

  • How do I burn a cd from the new iTunes

    Now that I downloaded the new iTunes on my windows computer , I can't figure out how to burn a cd. It used to be easy. What's up with that?? Can anyone help me out?

  • Look-up error after Upgrade

    Hi, The R/3 system  in our project was upgraded from 4.6 c to ECC 6. After the upgrade we are facing issues with the lmapping look -up. We have used RFC channel to  do look up and and java codes which calls the RFC and dose parsing. Right now after u

  • How can I reinstall the app store?? Help

    When my iPad updated I lost my app store..how can I reinstall

  • How update my list of articles?

    Hi, I have an excel file with the follow structure (for example): RecordKey    LineNum   Quantity   ItemCode List1              1                5              code1 List1              2                2              code2 List1              3       

  • Use catch block to do something other than handling exception?

    Hello, I have always been under the impression that the catch block should only handle the exception thrown by the try block? But now I'm reading a class where it's more or less used as an else if. Of course this works well, but I don't like it. What