TO_char - To_date

Asalam and Hello everyone...


I'll have some concept problem... I have a condition that

My created_date should be equal so and equal to 26 November 2009 and it must return 605 records

now when I do it with the following method returning 31 lines

where to_char (a.created, 'DD-MON-rr') > = 26 November 09 '

But if I do it with this method its works perfectly fine...

where to_date (a.created, 'DD-MON-rr') > = 26 November 09 '

now I want to know why its not returning all records when I use the function to_char

Welcome i m happy it helped you, please mark my answer :D

Tags: Database

Similar Questions

  • Select TO_CHAR (TO_DATE('20101006','DD-MON-YY'), 'DY') of double; ERROR

    Hi all
    I am the day by train to compaire wheather is a Sun or SAT...
    But it is showing this error.

    ORA-01861: literal does not match the format string
    01861 00000 - "literal does not format string.
    * Cause: Literals in the entry must be the same length as literals in
    the string format (with the exception of white space). If the
    "FX" modifier has been switched on, the literal must match exactly.
    with no extra spaces.
    * Action: Fix format string to match the literal.


    How can I compare...

    If TO_CHAR (TO_DATE('20101008','DD-MON-YY'), 'DY') not in ("SAT", "SUN") then
    ----------------------------
    end if;

    My id for entry in YYYYMMDD date format.

    Use the format YYYYMMDD character.

    SQL> select TO_CHAR(TO_DATE('20101008','yyyymmdd'), 'DY' ) day
      2   from dual;
    
    DAY
    ---
    FRI
    
    SQL>
    

    your code will be like:

      If TO_CHAR(TO_DATE('20101008','yyyymmdd'), 'DY' ) not in ('SAT', 'SUN') then
      ...
    
  • TO_CHAR to_date and functions are in error

    Hi guys,.

    My apologies if this look very stupid question to be posted on the forum, but I get errors for the following query:

    select to_date('sysdate','DD-MM-RR HH24:MI:SS') + 6/24 "Adding 6 hours ahead"
    from dual;
    

    It gives me the following error.

    ORA-01858: a non-digit character was found here where was waiting for a digital

    01858 00000 - "a non-digit character found here where was waiting for a digital".

    * Cause: Input data to convert using a date format model has been

    incorrect answer.  The input data did not contain a number where is a number

    required by the format model.

    * Action: Fix the input data or the date format model to ensure that the

    elements correspond to the number and the type.  And then try the operation again.

    What I want, or I'm trying to do is I want knowledge/duty to provide information to add 6 hours before the current system.

    I understand that this is because I am using to_date and "sysdate" but even if I change the to_char I always get an error

    ORA-01722: invalid number

    01722 00000 - "invalid number."

    * Cause:

    * Action:

    Finally, if I try to do something with sudo double table it always gives me error, I tried the following query.

    Query:

    select ('sysdate','DD-MM-RR HH24:MI:SS') + 6/24 "Adding 6 hours ahead"
    from dual;
    

    O/P

    ORA-00907: lack of right parenthesis

    00907 00000 - "lack the right parenthesis.

    * Cause:

    * Action:

    Error on line: column 74: 18

    May I know where I'm basically bad?

    Would be really appreciated your advice.

    Thank you!

    Function SYSDATE returns the DATE data type. So do not point using TO_DATE on it to convert it to DATE.

    What you need is

    SQL > alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS ";

    Modified session.

    SQL > select sysdate
    2, sysdate + '6' time-span
    3 double;

    SYSDATE SYSDATE + INTERVAL '6' H
    -------------------- --------------------
    APRIL 21, 2014 03:21:27 APRIL 21, 2014 09:21:27

    SQL >

    Please read Re: 15. I want to store Dates in the Format... Learn about implementing shaped and the DATE data type.

  • TO_DATE and to_char

    Hello

    Can someone explain to me why

    Select to_date (to_char (to_date('17.05.0012','dd.mm.yyyy'), 'dd'), 'dd.mm.rr') of double
    gives * 17.05.0012 * (what I think wrongly), but

    Select to_date (to_char (to_date('17.05.0012','dd.mm.yyyy'), ' dd.mm.yy' ")" | ") "dd.mm.rr") of the double
    gives * 17.05.2012 *.

    Thank you!

    Ok thank you! Seems it is explained more or less (only I can't do a patch, it is not my private Oracle).
    I asked a different colleague with Oracle to test and she got good results for 10.1 and 10.2.
    Well, it's not the biggest bug of my life! I'll close the question and thanks for the help!

  • Doubt function to_char (date, 'month')

    Hello

    Hope you have a great day.

    I have an installation of forms (Forms11gr2 11.1.2.2 64 bit on Red Hat EL 6 64 bit) where I have a forms module, where I am using the following code, which should return the name of the month in Spanish but he returns in English:

     RESULTADO := TO_CHAR(TO_DATE('10/10/2014','DD/MM/YYYY'),'MONTH');
    

    If I run the previous code on SqlDeveloper, it returns the month in Spanish without problem, but it seems that I should do something else either on the side of Weblogic.

    The database version is 11.2.0.3 64 bit.

    What should I do?

    Concerning

    Carlos

    You must set the NLS_LANG variable in your EPS file ("default.env" If you don't change it) on the appropiately weblogic server.

  • To_char stuck

    Hello

    I have the following sql query;

    Select

    XWE.employee_name,

    XWL. StartDateTime,

    XWL. EndDateTime

    of XXDP_WORKSHIFT_EMPLOYEE HENNIG,.

    Xwl XXDP_WORKSHIFT_LINES,

    Xwh XXDP_WORKSHIFT_HEADERS

    where xwe.resource_id = xwh.resource_id

    and xwl.xml_id = xwh.xml_id

    the output gives

    Employee_name Startdatetime

    MOl 2014-09-10 T 12: 09:13 + 02:00

    I want to make the startdattime for this line to 10/09/2014 or October 9, 2014.

    How is this possible for all lines with a differeft startdatetime?

    I tried various commands TO_char but that only works with the same startdatetime...

    Concerning

    ELCO

    What are the types of data of startdatetime and enddatetime?  If they are so FAR then just...

    Select

    XWE.employee_name,

    TO_CHAR (XWL. StartDateTime, 'DD-mm-YYYY'),

    TO_CHAR (XWL. EndDateTime, 'DD-mm-YYYY')

    If they are simply stored as strings (Varchar2) then you must first convert to DATE before the conversion to a string in the format that you want to display...

    Select

    XWE.employee_name,

    TO_CHAR (to_date (substr (XWL. StartDateTime, 1, 10), 'YYYY-mm-DD'), 'DD-mm-YYYY'),

    TO_CHAR (to_date (substr (XWL. EndDateTime, 1, 10), 'YYYY-mm-DD'), 'DD-mm-YYYY')

  • Filter values and to_date interactive report

    Hello world

    I am trying to add a filter in an interactive report on a field that is defined in the query as follows:

    Select TO_CHAR (TO_DATE (comm. MONTHS, 'MM'), 'MONTH') AS 'MONTHS' from sometable

    Comm. month is a date field

    It works properly when it shows values, they have the name of the month.

    The problem is when I try a filter to aid 'to' article. I can see the different names of months in the drop-down list and I can add to the list of filters (i.e.: MAY, JUNE) but when I click on Apply I behaving strangely, as always by selecting all the lines or not if you select anything.

    Any idea? Oh, I'm using Apex 4.0.2 btw.

    Try it here: Page 1

  • ORA-06502 use TO_NUMBER TO_CHAR

    Hello
    Oracle Database 10g 10.2.0.5.0.

    I have the error in this code:
    nSuper_ NUMBER(6,2);
    ...
    dbms_output.put_line('Super: ' ||  TO_NUMBER(nSuper_,'FM9G990D90'));
    ...
    I have to use "TO_CHAR"... but my test is not failure, why? :
    --a)
    SET SERVEROUTPUT ON
    DECLARE
      nSuper_ NUMBER(6,2);
    BEGIN
      nSuper_ := 666.12;
      dbms_output.put_line('Super: ' ||  TO_NUMBER(nSuper_,'FM9G990D90'));
    
    END;
    /
    Super: 666,12
    
    
    --b)
    SET SERVEROUTPUT ON
    DECLARE
      nSuper_ NUMBER(6,2);
    BEGIN
      nSuper_ := 6666.12;
      dbms_output.put_line('Super: ' ||  TO_NUMBER(nSuper_,'FM9G990D90'));
    
    END;
    /
    DECLARE
    *
    ERROR en línea 1:
    ORA-06502: PL/SQL: error  numérico o de valor
    ORA-06512: en línea 5
    
    --c)
    SET SERVEROUTPUT ON
    DECLARE
      nSuper_ NUMBER(6,2);
    BEGIN
      nSuper_ := 6666.12;
      dbms_output.put_line('Super: ' ||  TO_CHAR(nSuper_,'FM9G990D90'));
    
    END;
    /
    Super: 6.666,12
    Why 'a' step missed and 'b' in case of failure?

    Hello

    jortri wrote:
    Why 'a' step missed and 'b' in case of failure?

    Because Oracle RDBMS is (too) soft on you for the conversion of 'simple' like that (but that does not mean that you will get errors...).

    To_number function takes as input a string.
    You send her a number, then Oracle does this: + "Ok this guy is sending a number in a TO_NUMBER function when it must be a string, we will do an implicit conversion for him in a transparent way" +. "
    In fact, your to_number (my_number_variable, 'FM9G990D90') becomes this:

    to_number( to_char(my_number_variable) ,'FM9G990D90')
    

    But, as you can see, the function to_char is not given any format, so that it uses your default session, which might be a different way to the mask you provide to to_number function.

    Please run this to understand what your failure to_number function receives as input:

    select 6666.12 number_implicitly_converted from dual;
    

    By default, on my computer it shows this:

    Scott@my11g SQL>select 6666.12 number_implicitly_converted from dual;
    
    NUMBER_IMPLICITLY_CONVERTED
    ---------------------------
                        6666.12
    

    Now, if I use it as input of your with your format mask to_number function:

    Scott@my11g SQL>select TO_NUMBER('6666.12','FM9G990D90') back_to_number from dual;
    select TO_NUMBER('6666.12','FM9G990D90') back_to_number from dual
                     *
    ERROR at line 1:
    ORA-01722: invalid number
    

    Tadammm!

    Conclusion: Not to spoil use to_number/to_char/to_date functions.
    :-)

  • error in to_date

    Hello

    I am getting an error on the query, in the part of function 'to_date' below.
    select *
      from rf_bankaccount_avg t
     where t.month_year between
           to_char(to_date((SELECT ADD_MONTHS(LAST_DAY(SYSDATE), -7) + 1 AS FROM dual),'mm-yyyy')) and
           to_char(to_date((select last_day(sysdate - to_char(sysdate, 'DD')) from dual),'mm-yyyy'))
       and t.account_type = 1
       and t.addnl_factype_no = '0'
       and t.ret_factype = 'A'
       and t.company_bankcode = '';
    I get the error message ' ORA-01841: (full) year must be between-4713 and 9999 and not 0.

    Published by: 872435 on April 2, 2012 02:25

    Hello

    872435 wrote:
    Yes, I want to find the rows where t.month_year is between October 2011 and March 2012 inclusive. but t.month_year is varchar. so, how can I change the query?

    Depending on your data, use TO_DATE to convert t.month_year DATE; Use then BETWEEN as I showed earlier.

    Whenever you have a problem, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
    Explain, using specific examples, how you get these results from these data.
    Simplify the problem, if you can. By example, if the query performs several tasks, but you know how to do all of these things except find the correct values of month_year, and then after a problem where everything you do is find the correct values of month_year.
    Always tell what version of Oracle you are using.

  • Using to_char in order to extract "WW".

    Hello
    The other day asked me to write a sql statement that retrieves the number of weeks per year...
    with sample as 
      (select yr
        from
         (select 1999+level yr
           from dual
           connect by rownum<level+1
          )
      )   
      select yr, to_char(to_date('30/12'||yr,'dd/mm/rrrr'),'WW') dt
        from sample
    The above query returns the data correctly... but when I try:
    (the difference is written in "BOLD", I get the same number of weeks for each year - which is obviously not correct)
    with sample as 
      (select YR
        from
         (select 1999+level YR
           from DUAL
           connect by rownum<level+1
          )
      )   
      select YR, TO_CHAR(TO_DATE('*31*/12'||YR,'dd/mm/rrrr'),'WW') DT
        from sample
    Can someone describe why is this difference...?

    Note: I use db 10g v.2
    Thank you
    SIM

    Hi, Sim,

    sgalaxy wrote:
    Hello
    The other day asked me to write a sql statement that retrieves the number of weeks per year...

    A the applicant explains exactly what that means.

    with sample as (select yrfrom(select 1999+level yrfrom dual connect by rownum
    

    The above query returns the data correctly...

    Is this really good? It seems to say that all ordinary years (i.e., the years with only 28 days in February) have 52 weeks, and all this leap years (years where there is a 29 February) have 53 weeks.

    but when I try:
    (the difference is written in "BOLD", I get the same number of weeks for each year - which is obviously not correct)

    Why not? Every year (at least in the Gregorian calendar) have the same number of months. Why every year cannot have the same number of weeks?

    with sample as (select YRfrom(select 1999+level YRfrom DUAL connect by rownum
    

    Can someone describe why is this difference...?

    To study in detail what Peter said:
    WW '01' is always January 1 to January 7.
    WW '02' is always on January 8 to January 14.
    WW '03' is always on 15 January until 21 January.
    ...
    WW '08' is always from February 19 to February 25.
    WW '09' is February 26 March 4 in common years, but in leap years, it is February 26 to March 3.
    WW '10' is March 5 March 11 in common years, but in leap years, it is from March 4 to March 10.
    ...
    WW '52' is December 24, but on 30 December in common years, but in leap years, it is December 23 to December 29.
    WW '53' is December 31, (only 1 day) in common, but in leap years, it is December 30 and December 31.
    It is therefore 31 December always in week '53'. December 30 is in week 52 ' in common years, but in leap years, it is in week 53'. Looking at the week which includes December 30, you get '52' to 3 over 4 years and 53' like clockwork every 4th year (except at the turn of the century most).

    According to the definition of "WW" for a week, calendar years always have all 52 weeks (seen 7 days each), plus 1 week defective (having only 1 or 2 days).
    A different definition of a 'week' (and year) is the definition of ISO, where all weeks begin on Monday, and all the weeks have 7 days. The ISO year starts the Monday closest to January 1. Using these definitions, most years consist of 52 weeks, but every 5 or 6 years a year ago with 53 weeks.
    The display of the query after the last day of several weeks of ISO and watch what week they are in (which is the total number of weeks this year from ISO).

    SELECT     TO_CHAR ( TRUNC ( ADD_MONTHS ( DATE '2000-07-01'
                                      , 12 * LEVEL
                             )
                     , 'IYYY'
                   ) - 1
              , 'DD-Mon-YYYY   IYYY IW'
              )    AS iso_info
    FROM     dual
    CONNECT BY     LEVEL     <= 25
    ;
    

    When I try to understand nested expressions, like the preceding, I find this helps them to read from the inside (i.e., the more deeply nested point) and then work outward.
    ADD_MONTHS (DATE "2000-07-01', 12 * LEVEL") is 1 July of some year, which is in the middle of the ISO year.
    TRUNC (ADD_MONTHS (DATE "2000-07-01', 12 * LEVEL"), "IYYY") is the first day of a year of ISO.
    TRUNC (ADD_MONTHS (DATE "2000-07-01', 12 * LEVEL"), 'IYYY')-1 is the last day of a year of ISO.
    The result of the above query is:

    ISO_INFO
    ------------------------
    31-Dec-2000   2000 52
    30-Dec-2001   2001 52
    29-Dec-2002   2002 52
    28-Dec-2003   2003 52
    02-Jan-2005   2004 53
    01-Jan-2006   2005 52
    31-Dec-2006   2006 52
    30-Dec-2007   2007 52
    28-Dec-2008   2008 52
    03-Jan-2010   2009 53
    02-Jan-2011   2010 52
    01-Jan-2012   2011 52
    30-Dec-2012   2012 52
    29-Dec-2013   2013 52
    28-Dec-2014   2014 52
    03-Jan-2016   2015 53
    01-Jan-2017   2016 52
    31-Dec-2017   2017 52
    30-Dec-2018   2018 52
    29-Dec-2019   2019 52
    03-Jan-2021   2020 53
    02-Jan-2022   2021 52
    01-Jan-2023   2022 52
    31-Dec-2023   2023 52
    29-Dec-2024   2024 52
    

    There are many other ways to define the 'week' and 'year '.
    For example, we could say that all weeks begin on Sunday and I have 7 days a year start the Sunday closest to January 1.
    Another example: one could say that all weeks begin on Sunday and I have 7 days and a year beginning the first Sunday after December 31.
    In any case, there's how many weeks in a year depends on what your definition of 'week' and 'year '. If you hear the word 'year' out of context, there is a good chance that the speaker refers to the period that begins on 1 January and ends on 31 December. If you hear "week" out of context, there is much less certainty what the speaker means.

  • log in + date + to_char ('DAY'); to_char('D')

    Why do these two statements create different results?

    Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production
      SELECT closing_day,day_of_week,num_of_week
      FROM (
              SELECT
                   TO_DATE('01-01-2010', 'DD-MM-YYYY') + LEVEL AS closing_day,
                   TO_CHAR(TO_DATE('01-01-2010', 'DD-MM-YYYY') + LEVEL, 'D', 'NLS_DATE_LANGUAGE=AMERICAN') AS "NUM_OF_WEEK",
                   TO_CHAR(TO_DATE('01-01-2010', 'DD-MM-YYYY') + LEVEL, 'DAY', 'NLS_DATE_LANGUAGE=AMERICAN') AS "DAY_OF_WEEK"
              FROM  
                   dual
              CONNECT BY
                   LEVEL < SYSDATE - TO_DATE('01-01-2010', 'DD-MM-YYYY') 
      ) WHERE num_OF_WEEK NOT IN ('6','7');
      
      
      SELECT closing_day,day_of_week,num_of_week
      FROM (
              SELECT
                   TO_DATE('01-01-2010', 'DD-MM-YYYY') + LEVEL AS closing_day,
                   TO_CHAR(TO_DATE('01-01-2010', 'DD-MM-YYYY') + LEVEL, 'D', 'NLS_DATE_LANGUAGE=AMERICAN') AS "NUM_OF_WEEK",
                   TO_CHAR(TO_DATE('01-01-2010', 'DD-MM-YYYY') + LEVEL, 'DAY', 'NLS_DATE_LANGUAGE=AMERICAN') AS "DAY_OF_WEEK"
              FROM  
                   dual
              CONNECT BY
                   LEVEL < SYSDATE - TO_DATE('01-01-2010', 'DD-MM-YYYY') 
      ) WHERE day_OF_WEEK NOT IN ('SATURDAY','SUNDAY');

    This is because as TO_CHAR (..., 'DAY') adds white, so that every day in the week have the same length.
    You should change you SQL like

    WHERE RTRIM(day_OF_WEEK) NOT IN ('SATURDAY','SUNDAY'); 
    

    URS

  • To_char fn

    When user TO_CHAR(SYSDATE,'DD-MON-YY') result is shown to us but
    When I user TO_CHAR('24-JUL-11','DD-MON-YY') result is not displayed.
    It goes the same for the TRUNC function. But when I use it like this
    To_char(TO_DATE('24-Jul-11','DD-Mon-YY'),'DD-Mon-yy') I can get result.

    I want to internally what happens?
    Pls... If anyone knows send the response

    The SQL reference:

    When you use a SQL function or an operator with an argument of one data type other
    that it accepts, Oracle converts the argument type of data accepted.

    Unfortunately, TO_CHAR accepts only one argument of type DATE.
    It accepts either a string, a number, or a datetime type.
    "Default implicit conversion" seems to be the number string.

    URS

  • Problem in executing to_date

    Hello


    Under query is not executed: error: ORA-01858: a non-digit character was found here where was waiting for a digital

    Select to_date (SYSDATE, 'yyyyMMdd') of double;

    Published by: Balajiraam on February 28, 2011 10:05

    Balajiraam wrote:
    How do I get the date in the specified format without changing the NLS_PARAMETERS as shown below:

    Select double to_date('20090912','MMDDYYYY');

    As others have already pointed out, a date is not a format. You can't get a date in a specified format.

    If you want a character string that represents a date, you use the function TO_CHAR. In this case, it is not supposed to do since you already have the channel by hand. But you might

    SELECT to_char( to_date( '20090912', 'MMDDYYYY' ),
                    'MMDDYYYY' )
      FROM dual
    

    Justin

  • TO_CHAR date problem

    Select to_char ("6/9/0 ', ' dd/mm/yy") double

    I have dates as 9/6/0 varchar2. How can I convert to 09/06/00.

    THX
    select to_char(to_date('6/9/0', 'dd/mm/rr'), 'dd/mm/rr') from dual;
    
    TO_CHAR(
    --------
    06/09/00
    
  • Play with the date format TO_CHAR

    Hi all
    I'm learning how function TO_CHAR date format and code using the table double, but I had a few difficulties:
    SQL> select to_char(sysdate,'dl') test from dual;
    
    TEST
    -----------------------------
    Monday, December 20, 2010
    
    SQL> select to_char(sysdate) test from dual;
    
    TEST
    ---------
    20-DEC-10
    
    SQL> select sysdate test from dual;
    
    TEST
    ---------
    20-DEC-10
    
    SQL> select to_char('20-DEC-10','dl') test from dual;
    select to_char('20-DEC-10','dl') test from dual
                   *
    ERROR at line 1:
    ORA-01722: invalid number
    How can I place an explicit function TO_CHAR date?

    Best regards
    Valerie

    Valerie Debonair wrote:
    Hi all
    I'm learning how function TO_CHAR date format and code using the table double, but I had a few difficulties:

    SQL> select to_char('20-DEC-10','dl') test from dual;
    select to_char('20-DEC-10','dl') test from dual
    *
    ERROR at line 1:
    ORA-01722: invalid number
    

    How can I place an explicit function TO_CHAR date?

    Oracle converts implicitly your string to a date so that it can convert it to a string using your to_char function. Implicit conversion is based on your NLS_DATE_FORMAT settings, but you can never count on these implicit conversions.

    You can be...

    SQL> select to_char(to_date('20-DEC-10','DD-MON-RR'),'dl') from dual;
    
    TO_CHAR(TO_DATE('20-DEC-10'
    ---------------------------
    Monday 20 December 2010
    

    or

    SQL> select to_char(date '2010-12-20','dl') from dual;
    
    TO_CHAR(DATE'2010-12-20
    -----------------------
    Monday 20 December 2010
    

    Note that this one used Oracle fixed-date internal format YYYY-MM-DD, so if ever you use this method, you must specify the date string in this format. It also only deals with dates, not the component "hour".

Maybe you are looking for

  • -2519 error trying to create a PDM file

    I'm trying to create a file of PDM with a code on a 9073 that previously worked. He started giving me an error-2519, so after reading upward, I did a reset of the cRIO - no help, then did a software restart on the cRIO - without help, then did a refo

  • After replacing a hard drive

    I just replaced a hard drive on my pavilllion p6210f.  I need to know what to do next.  All I have is a 7 (64-bit) windows repair disc I made when I got the computer.  It did not come with any CD. What should I do next?

  • ScanJet G3110 - change location of registration at all times

    Rather than fix the save location by scanning scanning, I would like to permanently set the save location. How to get there? I run Windows 7, 64 bit.

  • Printing backwards! ???

    When I print a receipt or coupon directly from a Web site, printing is back! Why is this? And how to fix?

  • BlackBerry smartphone App using 4.5 not install in 9000 "BOLD"

    To install an application in BB is necessary that build approx. Special on a particular operating system (4.3, 4.5, 4.6, etc.). I build the APP in BB using JDE 4.5.0 that it installed and works fine on my 8310 BB which has OS 4.2.0 ok... But same app