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!

Tags: Database

Similar Questions

  • to_date and to_Char functions does not properly

    TO_CHAR SQL function below, NLS date format game does not: DD-MON-RRRR HH24:MI:SS, which gives an error: ORA-01722: invalid number

    SelectTo_char (January 1, 2014 ","MM-YYYY"") double;

    Wrong forum!

    This question has NOTHING to do with the Sql developer and belongs in the forum Sql and PL/SQL.

    SQL and PL/SQL

    Select To_char (January 1, 2014 ","MM-YYYY"") double;

    Your channel's day, then the month, then the string format and the year has only the month and year and month is a format DIFFERENT from that of the first string.

    Before repost you in the Sql and the forum PL/SQL examine the format of Date/time patterns in the Doc of the SQL language:

    Format patterns

  • 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.

  • Equivalent OBIEE TO_DATE and SUBSTR functions

    I have the formula for the next column, which works correctly:

    SUM (CASE WHEN (TimeStampDiff (SQL_TSI_month, "Registration - College". "" Effective colleges F. ((("' Program Start Date ', current_date)) / 12 < 6 THEN 1 ELSE 0 END)


    I want to replace the current_date with scope of practice. Because the scope of practice is currently not in a date format (e.g. 201213, 201314, 201415), I need to use the TO_DATE and SUBSTR functions OBIEE equivalent to convert this field into a format that can be used by the TimeStampDiff function.

    The current (outside OBIEE) SQL for the conversion of the year at a date looks like this:

    To_date (substr (Fiscal_Year, 1, 4) |) '09', "YYYYMM")


    I tried to replace current_date in the column formula above by the following, but it didn't work:

    To this day (Substring ("registration - College". "D time". " "Exercise" FROM 1 to 4) | '09', "YYYYMM")

    TO_DATETIME (LEFT ("registration - College". "D time". " ("' Exercise ', 4) | ("/ 09/01 ', ' yyyy/mm/dd')

    Good course assuming that "registration - College". "D time". " "' Exercise ' is of type varchar, otherwise you will first need to cast as varchar or LEFT won't like it (but the error will tell you what the problem is exactly).

  • Convert and To_Char in where clause does not

    Hello

    I try to get the following sql beating, but it always generates an error. Any ideas?

    SELECT

    e_Equipment.EQU_ID,

    e_Equipment.EQU_PC_name,

    e_Equipment.EQU_DESCR,

    e_Equipment.EQU_SERIAL_NO,

    e_Equipment.EQU_STATUS,

    a_POBSYSENUMS. PSS_ID

    Of e_equipment

    LEFT JOIN

    A_POBSYSENUMS

    ON e_Equipment.EQU_STATUS = CONVERT (A_POBSYSENUMS. PSS_ID, ' varchar (2)') AND A_POBSYSENUMS. PSS_PSE_PK = '76'

    WHERE

    e_Equipment.EQU_ORG_PK = 8271;

    Thank you very much

    Christina

    Looks like you are trying to use the MS SQL Server syntax rather than the Oracle syntax.

    You did not say why to_char does not work for you...

    Try...

    e_Equipment.EQU_STATUS = TO_CHAR (A_POBSYSENUMS. PSS_ID)

  • Case and To_Char

    Hello

    If I want to 'white' in the columns of the Department where there is 0 pay... what additional question should I include and where? (I tried several versions of To_char and I keep getting errors... IE, if in Dept 30 below instead of list 0 will display nothing or empty...

    Thank you!


    SQL > select job_id JOB,.
    2 sum (case when department_id = 30 end of salary otherwise 0) dept30,
    3 sum (case when department_id = 60 here end of salary otherwise 0) dept60,
    4 sum (case when department_id = 100 where 0 otherwise end of salary) dept100,.
    5 sum (case when department_id = 110 here end of salary otherwise 0) dept110,
    6 Sum Total_Sal
    7 employees
    8 job_id group
    9.

    WORK DEPT30 DEPT60 DEPT100 DEPT110 TOTAL_SAL
    ---------- ---------- ---------- ---------- ---------- ----------
    0 0 0 12000 12000 AC_MGR
    0 0 0 8300 8300 AC_ACCOUNT
    IT_PROG 0 28800 0 0 28800
    ST_MAN 0 0 0 0 36400
    0 0 0 0 4400 AD_ASST
    11000 0 0 0 11000 PU_MAN
    SH_CLERK 0 0 0 0 64300
    AD_VP 0 0 0 0 34000
    FI_ACCOUNT 0 0 39600 0 39600
    FATYTY 0 0 0 0 13000
    0 0 0 0 10000 PR_REP

    WORK DEPT30 DEPT60 DEPT100 DEPT110 TOTAL_SAL
    ---------- ---------- ---------- ---------- ---------- ----------
    0 0 12000 0 12000 FI_MGR
    13900 0 0 0 13900 PU_CLERK
    SA_MAN 0 0 0 0 61000
    0 0 0 0 6000 MK_REP
    AD_PRES 0 0 0 0 24000
    0 0 0 0 250500 SA_REP
    0 0 0 0 6500 HR_REP
    ST_CLERK 0 0 0 0 55700

    Change the value to 0 by a NULL value

    SQL> ed
    Wrote file afiedt.buf
    
      1  select job_id JOB,
      2         sum(case when department_id = 30
      3                  then salary
      4                  else null
      5               end) dept30,
      6         sum(case when department_id = 60
      7                  then salary
      8                  else null
      9               end) dept60,
     10         sum(case when department_id = 100
     11                  then salary
     12                  else null
     13               end) dept100,
     14         sum(case when department_id = 110
     15                  then salary
     16                  else null
     17               end) dept110,
     18         sum(salary) Total_Sal
     19    from employees
     20*  group by job_id
    SQL> /
    
    JOB            DEPT30     DEPT60    DEPT100    DEPT110  TOTAL_SAL
    ---------- ---------- ---------- ---------- ---------- ----------
    IT_PROG                    28800                            28800
    AC_MGR                                           12008      12008
    AC_ACCOUNT                                        8300       8300
    ST_MAN                                                      36400
    PU_MAN          11000                                       11000
    AD_ASST                                                      4400
    AD_VP                                                       34000
    SH_CLERK                                                    64300
    FI_ACCOUNT                            39600                 39600
    FI_MGR                                12008                 12008
    PU_CLERK        13900                                       13900
    SA_MAN                                                      61000
    MK_MAN                                                      13000
    PR_REP                                                      10000
    AD_PRES                                                     24000
    SA_REP                                                     250500
    MK_REP                                                       6000
    ST_CLERK                                                    55700
    HR_REP                                                       6500
    
    19 rows selected.
    

    Justin

  • Using NVL and to_char

    Hi guys,.

    Help needed here; I use the following code to create a report in Oracle APEX 3.0:

    Select 'EBA_BT_PROBLEM '. "" ID "as the"BUG ID. "
    'EBA_BT_PROBLEM '. "" Subject of "as"TOPIC ",.
    'EBA_BT_URGENCY '. "" URGENCY_NAME "as a"PRIORITY. "
    'EBA_BT_USER '. "" New_login_name "as" ASSIGNED to "
    'EBA_BT_PROBLEM '. "' SUBMITTED_BY_ID ' as ' PRESENTED BY '.

    of "EBA_BT_PROBLEM" INNER JOIN "EBA_BT_USER" ON "EBA_BT_PROBLEM". "" ASSIGNED_TO_ID "="EBA_BT_USER. " "" IDENTITY CARD ".
    "JOIN THE"EBA_BT_URGENCY"ON"EBA_BT_PROBLEM" URGENCY_ID"="EBA_BT_URGENCY. " "" IDENTITY CARD ".
    "JOIN THE"EBA_BT_STATUS"ON"EBA_BT_PROBLEM" BATCH.
    = "EBA_BT_STATUS". "" IDENTITY CARD ".
    "JOIN THE"EBA_BT_PRODUCT"ON"EBA_BT_PROBLEM" PRODUCT_ID.
    = "EBA_BT_PRODUCT". "" IDENTITY CARD ".
    "JOIN THE"EBA_BT_CATEGORY"ON"EBA_BT_PROBLEM" STUFF. "
    = "EBA_BT_CATEGORY". "" IDENTITY CARD ".

    where
    TO_CHAR ("EBA_BT_PROBLEM". "Batch") = NVL (: P64_STATUS, to_char ("EBA_BT_PROBLEM".) " BATCH'))

    It returns all the fields and the data I'm after, is the only issue I'm having with my 'where '. I have a drop down selection called P64_STATUS, box that lets choose me among several options that will give me in turn to report different results. He does this ok, but when it is set to the value 'null' or a default, I want to just give me all the possible lines to select it; Instead he gives me nothing.

    So essentially, I need to correct the code in my where clause, I think especially here:
    NVL (: P64_STATUS, to_char (* 'EBA_BT_PROBLEM'.)) (("" BATCH "*))
    in order to give me what I'm after

    I tried to explain what I'm after as best I can, any help would be much appreciated. Thank you!

    In APEX NULL values, or often "null %. Then you might want to check for this in your selection.

    See also: http://www.inside-oracle-apex.com/display-null-yes-and-null-problem/

    where
    (to_char("EBA_BT_PROBLEM"."STATUS_ID") = :P64_STATUS
      or :P64_STATUS is null
      or :P64_STATUS = '%null%')
    

    You can also assign the value null to the selection list something like -1. Then the number conversion should work

    where  EBA_BT_PROBLEM.STATUS_ID = decode(:P64_STATUS,
                                               '-1', EBA_BT_PROBLEM.STATUS_ID,
                                               null, EBA_BT_PROBLEM.STATUS_ID,
                                               to_number(:P64_STATUS) )
    

    Published by: Sven w. on April 27, 2011 17:29

    Published by: Sven w. on April 27, 2011 17:31

  • Question about the Date and TO_CHAR fields

    I ran into a date format today I need to replicate but I don't default with. I work with a based REST webservice that wants its dates and hours of formatting to ' 2009 - 09-29T 17: 00:00 - 04:00 '. When is 2009-09-29 17:00 et. Is there an easy way to reproduce this output in oracle, so I can feed him in the web service?

    You are looking for:

    with my_tab as (select to_timestamp_tz('2009-09-29T17:00:00-04:00', 'yyyy-mm-dd"T"hh24:mi:ssTZH:TZM') col from dual)
    select to_char(col, 'yyyy-mm-dd"T"hh24:mi:ssTZH:TZM') ts_col
    from   my_tab;
    
    TS_COL
    -------------------------
    2009-09-29T17:00:00-04:00
    

    Published by: Boneist on October 6, 2009 16:59
    Realized it's timestamp-> tank you were after, not the reverse. Fixed!

  • SQL diff result to_date and to_date

    I have the SQL on 10.2.0.4 database with where clause

    slect count (*) from abc_table where
    "a.SRVC_FROM_DT between January 1, 2005" and on December 31, 2006.

    When I came across it it gives me results like 400, when I RAM it gives me 2000 count of query below.

    The second one is correct, what could be the reason to get resullts diff.

    slect count (*) from abc_table where
    a.SRVC_FROM_DT between to_date('01-JAN-2005','dd-mon-yyyy') and to_date ("31 December 2006","dd-mon-yyyy" ");

    appricaite your help.

    When you specify "between January 1, 2005" and the 31 December 2006 ' oracle reads in January 1, 2005 00:00:00 "format of an hour... so if you have something like 03:03:00 '(e.g..) January 1, 2005, stored in the column it will not play... then that between to_date('01-JAN-2005','dd-mon-yyyy') and to_date ("December 31, 2006 ',' dd-mon-yyyy '); changes January 1, 2005 03:03 ' on January 1, 2005 "only. It verifies that the date does not check the time factor.

    Anand

    Published by: Anand... Sep 17, 2008 01:08

  • Concatenate the date and time that are stored in two different date columns

    Hello

    I have to select date two columns from two different tables a date and another over time.

    I want to concatenate these two columns and format the result form dd/mm/yyyy hh24

    But I get error invalid number

    For example

    create table as datetime

    (select to_date (' 21/01/2014 ',' dd/mm/yyyy') as dt, to_date('08:00','hh24:mi') like double MC

    )

    Select to_char(dt||) TM, "dd/mm/yyyy hh24") of datetime

    I use oracle 10 g

    Help, please.

    Hello

    Roger wrote:

    ... If you need to take the party date to a date column and the time of anonther part, then you must first convert them to a string, concatenate them and convert them to date.

    You don't need to do this.  What you have described is a way to do it, but this isn't the only way.

    If d1 and d2 are the two DATEs, you can get year, month and day of d1 combined with hours, minutes, and seconds from d2 liike this:

    TRUNC (d1) and (d2 - TRUNC (d2))

    Nesting TO_DATE and TO_CHAR in Oracle, is almost never the best way to do anything.  Oracle provides many functions (for example, TRUNC) to manipulate dates, but also of DATE arithmetic.

  • How to convert varchar to DateTime?

    Hi all

    I have a field - "final payment".

    Data - type Varchar.

    Last completion date must be in the date format. So I want to convert Varchar to Date.

    How can I convert? Can someone please help me solve this problem.

    Hi Nicolas,.

    Gayathri Venugopal wrote:

    I have a table - order and I have a field " Latest_Completion_Date " which is in the format Varchar - ' 20150804'.

    select Latest_Completion_Date from order 
    output- 20150804
    

    I want to convert Latest_Completion_Date - '20150804' in Date format - 15-SEP-07 ".

    How to convert it?

    The column ORDER. LATEST_COMPLETION_DATE with the VARCHAR2 data type?

    How are "Last date" element filling in the form?

    You can use to_date and to_char in combination to get the required format:

    select to_char(to_date(latest_completion_date,'YYYYMMDD'),'DD-MON-RR') latest_completion_date
      from order
    

    Kind regards

    Kiran

  • Partition key would exist in local index, if so it should be first or last or is not serious?

    Hello

    I'm trying to find the rule for:

    -J' have a partitioned table every day and each partition has about 10 GB.

    -J' need to keep the data in 3 months.

    -I need to partition cutting happens.

    I'm trying to find if I need to use the local index the partition key or not.

    I am currently adding as the first column of the index.

    In my research on the web and with colleagues, I find three different answers:

    -It is not required to add local index the partition key.

    -It is compulsory and must be the first position.
    -It is necessary and should be the last position.

    I share below the criation of table as an example:

    CREATE TABLE MY_BIG_TABLE
    (
      MY_SOURCE             VARCHAR2(50 CHAR)       NOT NULL,
      MY_FILENAME           VARCHAR2(255 CHAR)      NOT NULL,
      MY_DATE               DATE                    NOT NULL,
      MY_ID                 VARCHAR2(50 CHAR)       NOT NULL,
      MY_ORIG_GROUP         VARCHAR2(50 CHAR)       NOT NULL,
      MY_DEST_GROUP         VARCHAR2(50 CHAR)       NOT NULL,
      MY_DURATION           NUMBER,
      MY_NR_EVENT           NUMBER
    )
    TABLESPACE MY_BIG_TABLESPACE_1
    PARTITION BY RANGE (MY_DATE)
    INTERVAL (NUMTODSINTERVAL(1,'DAY'))
    (  
      PARTITION P_FIRST VALUES LESS THAN (TO_DATE(' 2014-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
        LOGGING
        NOCOMPRESS 
        TABLESPACE MY_BIG_TABLESPACE_1
    )
    LOGGING 
    NOCOMPRESS 
    NOCACHE
    NOPARALLEL
    MONITORING
    /
    CREATE UNIQUE INDEX I_MY_BIG_TABLE
     ON MY_BIG_TABLE (
       MY_DATE,           
       MY_SOURCE,    
       MY_FILENAME,       
       MY_ID,             
       MY_ORIG_GROUP,     
       MY_DEST_GROUP     
     )
     TABLESPACE MY_BIG_IDX_TABLESPACE_1
     LOGGING
     NOCOMPRESS
     NOPARALLEL
     LOCAL
    /
    

    Best regards

    Ricardo Tomas

    Well, I don't like this example because I would tell you to use on your text string to_date and to_char on your column.

    Let's say if you have a partition of the range with a value of one month of data in the partition and you want to select the data for a given day. Oracle must be able plum of the score, but then you have to complete the partition scanning unless there was an index containing the day (assuming it's the partition key)

  • varchar to date

    Hello

    I would like to convert varchar value stored in a table in order to view a converted date...

    as below

    the value in the column has values such as "January 2013', ' March 2014'... etc.

    I want to display in the form of "Jan 2013', ' March 2014'... i.e. the short form..."

    I tried to use the to_date and to_char... but not of much use...

    can someone please help...

    Thanks in advance...

    RK

    SQL >-generating sample data:

    SQL > with t as (select 'January 2013 "str of union double

    2 Select "March 2014' double '.

    3            )

    4  --

    5 - the actual query:

    6  --

    7. Select str

    8, to_char (to_date (str, ' month yyyy ',' nls_date_language = american'), "My yyyy")

    9 t

    10.

    TO_CHAR (TO_DATE (S STR

    ------------ -----------------

    January 2013 Jan 2013

    March 2014 2014 Mar

    2 selected lines.

  • Vchar2 in time - PL Sql

    I have 2 columns time in my data in vchar2 format. I tried several suggestions from this forum on how to convert (to_date and to_char) and can't make it work. My ultimate goal is to remove these 2 times to see the difference in minutes.

    BLOCKED_DATE RMBL_TIME_START RMBL_TIME_STOP
    01/05/2012 07:00 17:00
    01/05/2012 07:00 19:00
    05-02-2012 07:30 19:30
    05-02-2012 07:30 17:30
    03/05/2012 07:00 17:00
    03/05/2012 07:00 19:00
    04/05/2012 07:30 17:00
    04/05/2012 07:30-19:00

    Source: room_blocked_vw

    I get an error invalid number when you use to_char or simply by subtracting the 2 fields. I get error of non-numeric values with to_date. I tried to concatenate the date and time with these functions as well.

    Thanks in advance for your help.

    Jason

    A bit similar to Etbins solution:

    select 1440*
        to_number(to_date(lpad(RMBL_TIME_STOP,5,'0'),'hh24:mi')
                    - to_date(lpad(RMBL_TIME_START,5,'0'),'hh24:mi')
           ) from yourtab;
    
  • Conversion of date format?

    Hello

    I have a collar (varchar) with values like 2010-02-23 12:42:31 I want to convert varchar to date MM-DD-YYYY format

    You can use TO_DATE and TO_CHAR:

    SQL> SELECT TO_CHAR(TO_DATE('2010-02-23 12:42:31','YYYY-MM-DD HH24:MI:SS'),'MM-DD-YYYY') AS NEW_DT FROM DUAL;
    
    NEW_DT
    ----------
    02-23-2010
    

    However, you should seriously consider converting these VARCHAR columns that store dates in the DATE data types.

Maybe you are looking for

  • Dv7-7202tx Notebook PC ENVY: Wireless not working not

    Hello My wireless stopped working last night and the function button is orange. I tried to restart, fixing through the System Mechanic, but that did not work. Of course, I didn't have internet access so I couldn't download a driver, but I don't know

  • the text went too big and I don't know how to make it smaller

    the text got too big and I don't know how to make small new

  • I can't log on to windows in normal mode.

    Hi, I am running 32-bit vista and my computer froze on me earlier so I turned off and restarted. but I was unable to boot in normal mode, it does not load in the user log in page where you would put your password to log on windows. so right now I'm i

  • 3 years old DELL P513w lost connection with the wired PC &amp; wireless

    Back in Jan. 2010 I purchasea a Dell P513w printer. Since setting it up its been sitting in the other end of my PC room. It worked fine both wireless and whan the cable attached. It justsat there unused except for printing probably a couple dozen pic

  • BlackBerry Z10 attach files to send

    When I open my email account in browser I cant find any attachments options how can I reach my files from there.is it the bug of the phone? but when I open the email hub there are the attachment option.then why not, I see in the browser.