Converting Number to Date in Oracle sql

I have some values in field1 like
20110820,
20110821,
20110822
which is a number datatype and
which is something like yyyymmdd.
I want to convert it to date format as 'dd/mm/yyyy'.
I have to use in select query something like if (A.field1=0, 01/01/2000, A.field1).
How can i achieve this ?

to_Date(substr(date1,7,2)||'/'||substr(date1,5,2)||'/'||substr(date1,1,4),'dd/mm/yyyy')

Similar Messages

  • I want to convert number to hours in oracle 10 like this.

    Dear All
    Some can help me
    I want to convert below MS-SQL query in oracle 10g. please help me.
    for eg:
    Select numasdate,
    Cast(numasdate / 60 as Varchar) + ' hours ' +
    Cast(numasdate % 60 as Varchar) + ' minutes'
    as [TotalHoursAndMinutes]
    From
    #SampleTable
    Output:
    9436 157 hours 16 minutes
    537 8 hours 57 minutes
    9323 155 hours 23 minutes
    12525 208 hours 45 minutes
    Edited by: Parwez on Jan 1, 2013 5:33 AM

    I want to convert number to hours in oracle 10g like this.
    537 8 hours 57 minutes
    9436 157 hours 16 minutes
    12525 208 hours 45 minutesTry this...
    Ranit>> with xx as(
      2      SELECT 537 num from dual UNION ALL
      3       SELECT 9436 num from dual UNION ALL
      4       SELECT 12525 num from dual
      5  )
      6  select
      7       num,
      8       FLOOR(num/60)||' hrs' as "hrs",
      9       MOD(num,60)||' minutes' as "minutes",
    10       FLOOR(num/60)||' hrs  '||MOD(num,60)||' minutes' as "Hours.Mins"
    11  from xx;
           NUM hrs                                          minutes                                          Hours.Mins                                                                                                        
           537 8 hrs                                        57 minutes                                       8 hrs  57 minutes                                                                                                 
          9436 157 hrs                                      16 minutes                                       157 hrs  16 minutes                                                                                               
         12525 208 hrs                                      45 minutes                                       208 hrs  45 minutes                                                                                                Edited by: ranit B on Jan 1, 2013 6:51 PM
    --- Hey John... I just did it and saw your hint now !!!

  • How to view execution history for any date in oracle SQL developer tool ?

    hi, i want to view some executed queries(2 months before) in oracle SQL Developer. if i press F8 it shows execution history for only last 30 days. is there any option(query) or something to view execution history for specific date ? i want to see some queries, which is executed before 2 months in my oracle SQL developer tool. Pls help me out.

    sb92075 wrote:
    943838 wrote:
    hi, i want to view some executed queries(2 months before) in oracle SQL Developer. if i press F8 it shows execution history for only last 30 days. is there any option(query) or something to view execution history for specific date ? i want to see some queries, which is executed before 2 months in my oracle SQL developer tool. Pls help me out.it will never occurWhy not? Are you a member of the product team that develops SQL Developer?
    To the OP, there is a forum for SQL Developer
    SQL Developer
    And there's also a sticky on the forum for product enhancement requests
    "Feature Requests, Extensions and General Collateral "
    Cheers,

  • How to convert milliseconds to date format in sql query

    Hi All,
    The following code is in java.     
    String yourmilliseconds = "1316673707162";**
    Date resultdate = new Date(Long.parseLong(yourmilliseconds));
    could you plese tell me how to convert milliseconds into date format in query and comparing with another date like(sysdate-3)

    Hello,
    http://stackoverflow.com/questions/3820179/convert-epoch-to-date-in-sqlplus-oracle
    Regards

  • How to convert from ifs date format to sql based dates

    I want to write a sql query using dates, to search an ifs
    database. Ifs stores dates as numbers created using the
    java.util.Date class. These dates are accurate to seconds.
    PLSQL uses a different format.
    What I need is a PLSQL function that converts PLSQL date format
    to and from the java.util.date format.
    This is an example of what I would like to do.
    String classname = "DOCUMENT";
    String whereclause = "CREATEDATE > theNeededFuction(to_date('01-
    Jan-2001', 'DD-Mon-YYYY'),'j')";
    Selector mySelector = new Selector(login.getSession());
    mySelector.setSearchClassname(classname);
    mySelector.setSearchSelection(whereclause);
    I do realize that I could simply convert the date in java, but
    in the long run, I want to use the oracle tools that support
    busness day calulations.
    -Mitch

    Hi Mitch - our ViewSpecification functionality automatically
    includes an Oracle Date column, which is derived from the java
    date values we store. These views are the supported way of
    performing read-only operations against an iFS instance.
    For yor reference, the Oracle date column is derived using the
    following SQL operation (e.g. for createdate):
    to_date('01-JAN-1970', 'DD-MON-YYYY') + (createdate/86400000)
    regards,
    dave

  • Convert varchar to date in OBIEE-sql server database

    Hi we have SQL server database,
    and we need to convert varchar to to_date .
    In OBIEE we use evaluate,cast etc on Oracle......Not sure about sql server..please help

    i am usiing below formula in my reports-answer side:
    Cast((case when "Job CV Fact"."Total Cv Sent" is not null then "DATE DIM".Date end)as Date)
    below error is coming:
    A general error has occurred. [nQSError: 46046] Datetime value 01/01/08 does not match the specified format. (HY000)
    cast("DATE DIM".Date as date) the above error comes :)

  • How to Convert Normal XML date or Oracle date to JDE Julian Date

    We can do a simple mathematical step in XSLT :
    'xpath20:format-dateTime(xpath20:current-dateTime(),"[Y0001][d001]") - 1900000'
    Or in SQL :
    Select to_char(sysdate,'YYYYDDD')-1900000 from dual;
    Julian Date is: Year in 4 digits, YYYY, and Number of days in 3 digits, DDD
    JDE Julian Date is Julian Date -1900000 (ie it counts Julian date from 1900 Year)
    "[Y0001][d001]” returns date in Year in 4 digit + number of days in 3 digits. This is the Julian date.
    Subtracting 1900000 ( ie YR ’1900’ & DAY ‘000’) gives the required JDE Julian Date.
    Edited by: prakash.pankaj on Jul 8, 2011 2:13 PM
    Edited by: prakash.pankaj on Jul 8, 2011 4:02 PM
    Edited by: panks on Jul 20, 2011 3:43 PM

    Hi,
    getTime() (in Date) will give you that date in milliseconds since January 1, 1970 00:00:00 GMT.
    To my knowledege, this is the same as Unix date format.

  • Convert varchar2 to date in oracle

    how to covert varchar2 (30) to date fromat
    example '01/01/2007' to 01/01/2007
    thanks in advance
    Reddy

    I want to insert into my new table the data in the
    form DD-MON-RRRRIf your new table has the data type as DATE then you don't insert dates in any particular format, you just insert values that are DATE datatypes.
    The format is only important when you view the data.
    e.g.
    SQL> create table dt (mydate DATE);
    Table created.
    SQL> insert into dt values (to_date('01/01/2008','DD/MM/YYYY'));
    1 row created.
    SQL> insert into dt values (to_date('01-FEB-2008','DD-MON-YYYY'));
    1 row created.
    SQL> insert into dt values (to_date('20080402','YYYYMMDD'));
    1 row created.
    SQL> select * from dt;
    MYDATE
    01/01/2008 00:00:00
    01/02/2008 00:00:00
    02/04/2008 00:00:00
    SQL> alter session set nls_date_format='DD-MON-YYYY';
    Session altered.
    SQL> select * from dt;
    MYDATE
    01-JAN-2008
    01-FEB-2008
    02-APR-2008
    SQL>Edit:
    Sorry, forgot to say...
    This just demonstrates that any format of string can be inserted into a date column if the format string is specified correctly and it also demonstrates that what is stored is just a date, the format of which is determined by the settings of the tool you are using to retrieve the data (unless you specify e.g. to_char(date_column, 'DD-MON-YYYY') in the SELECT statement to convert it to a string again manually)
    Message was edited by:
    BluShadow

  • Convert number to date

    Hello.
    I'm new at this stuff and need a hand with a function.
    I have a Customer table that has a Date set as a number. 
    When I drag this field on to the report I get the following: 20,071,101.00
    Which makes complete sense since it is a number field.
    How do I convert this field to a date format?
    I tried the following:
    cDateTime ({CUS.DATESTART})
    Unfortunately, I'm doing something wrong as it is providing me with the following error:
    Error: Dates must be between year 1 and year 9999
    What am I doing wrong?
    Perhaps there is a much easier method then trying to create function...
    Thanks in advance for your assistance.
    Stephane

    Hello Raghavendra.
    Your solution has provided my answer.
    I will provide my final solution for others to view:
    Date(tonumber(left(totext({CUS.DATESTART},'##'),4)),tonumber(mid(totext({CUS.DATESTART},'##'),5,2)),tonumber(right(totext({CUS.DATESTART},'##'),2)))
    Notice how I substituted the actual date with the field(number).
    Here is reported field: 01/11/2007
    Note: my field value at this point was equal to CUS.DATESTART = 20,071,101.00
    Thank you very much for your quick assistance.
    Stephane

  • Load Xml Data in oracle (SQL LOADER)

    i have written a sql loader script given below....
    load data
    infile 'contact1.xml' "str '</CONTACT>'"
    truncate
    into table XmlTest
    dummy filler terminated by ">",
    Location_id enclosed by "<Location_id>" and "</Location_id>",
    fname enclosed by "<fname>" and "</fname>",
    lname enclosed by "<lname>" and "</lname>"
    the content of the contact1.xml is given below.....
    <CONTACT>
    <Location_id>1</Location_id>
    <fname>Robert</fname>
    <lname>Jones</lname>
    </CONTACT>
    <CONTACT>
    <Location_id>1</Location_id>
    <fname>Robert</fname>
    <lname>Jones</lname>
    </CONTACT>
    the script works fine for the given xml... but if one of the tag in the xml is changed to below syntax....
    <CONTACT Location_id="1">
    <fname>Robert</fname>
    <lname>Jones</lname>
    </CONTACT>
    <CONTACT Location_id="1">
    <fname>Robert</fname>
    <lname>Jones</lname>
    </CONTACT>
    what modification is required in the script to read such xml...Kindly Help!!

    And in what way does this relate to SQL and PL/SQL?
    There is a demo of loading XML in Morgan's Library under SQL*Loader.
    But as your question is off-topic here ... if the demo does not help you please continue this by starting a thread in the correct forum: Database General.
    Thanks.

  • Converting 99999999 to date datatype through sql/ssis

    Hi,
    I am developing an ETL in which we get this column which holds the value 99999999 in one of the columnwhich is of numeric datatype. User wants that field to be date time in destination. Please help me on how to convert that value into date datatype in SSIS.
    Please........

    Thank you Rajen,
    But I have used Collasce to solve this issue.
    COALESCE
    (NULLIF(t1.dtetrm,
    '99999999')
    ,'20991231')

  • Convert a Number to time in Oracle

    Hi,
    In a oracle database table i have a colum that gives the value from 0 to 2359. I want to convert Number to time in Oracle. Any i dea on the query for this.
    I have tried
    SELECT TO_CHAR('2342','HH:MI') "Time"
    FROM dual;
    but it is not functioning.
    Thanks

    The Number that i want to convert to Time is of the
    columns of the same table and depending on its value,
    i want to display it as Time.
    Thanks,Well it sounds like you certainly have no clue what you are doing whatsoever. I predict a bright future for you.
    Here's some advice. If the column should have a date or time in it then use a date or time type column. If you are creating a variable data type column then ASAP get a book on SQL before you fuck things up worse then you have.
    There is no great mystery here. There is the right way (as suggested by WorkForFood) and there is the wrong way (whatever you are doing). So do what WorkForFood told you or just go away because nobody cares to help make a disaster.

  • Insert data from oracle  to sql server

    we have running R12.1.1 .
    our company wants to deploy some CRM Application with sql server database. Continuously we have to insert data ( some fields from some tables of Order Management module ) from ORACLE -----------> SQL Server
    My Questions are :
    1. What are possible methods to insert data from ORACLE -----------------> SQL Server ?
    2. What are pros and cons of each method ?
    3. What is performance over load of each method ?
    PLease share your valuable knowledge / ideas / suggestions
    thanks

    What is a maximal latency for data changed in Oracle come into MS SQL?
    this data will be updated in CRM after 24 hours.Does it mean that data replicated from Oracle will be updated in MS SQL and should be replicated back?
    i want to know more details about these APIs etc and middle layer.what API? In MS SQL you can use Linked server and write SQLs that select from Oracle tables via that linked server and insert/update/delete into MS SQL. You can organize these SQLs into T-SQL procedures and run them in jobs.
    Also you can use MS SQL replication, snapshot or transactional, which is ugly because it places triggers on Oracle tables. I doubt that this will be approved by app vendor.
    Also you can use Oracle Streams via Transparent Gateway for MS SQL, which will be quite heavy solution.
    Also, if real-time replication is needed, you can use "middle layer" Oracle Golden Gate, which may be quite pricy for 30 tables.
    Also, if real-time replication is needed, you can use 3-rd party middle layer like DataCurrents or others.

  • Convert type dats to oracle type date

    Hi guys,
    I have abap field
    data: begin of itab occurs 0,
            dat type dats,
    end of itab.
    how can I convert abap field dat into oracle type DATE, so I can insert dat into that oracle field?
    thanks,
    nihad
    Edited by: nihad omerbegovic on Mar 25, 2009 5:47 PM

    Thanks for suggestion, now I got different error
    Database error text........: "ORA-01858: a non-numeric character was found
    where a numeric was expected#"             
    When I debugg I have some unxpected field values in internal table itab:
    DAT      USNAM        NOVI                                              
    X2009032|0NIHADOM     |                                                   
    X2009032|0NIHADOM     |                                                                               
    But, it should be like this
    DAT      USNAM        NOVI                                              
    20090320|NIHADOM     |X
    20090320|NIHADOM     |X       
    Any idea why I got indicator X in DAT field but it should be in NOVI. Is that why I got above error?
    Thnaks,
    Nihad

  • Extraction of data from Planning and load it into Oracle/SQL server (RDBMS)

    Hi All,
    ODI can extract data from Oracle/SQL server RDBMS and load it into Hyperion planning, but I wanted to know if it is possible to extract data from Hyperion Planning through ODI and load it into Oracle or SQL server RDMBS i.e the other way round.
    Kindly let me know if that is possible or not,If yes then please let me know what is the exact process to achieve this through ODI.
    Thanks & Regrads,
    Gurpreet

    Yes this can be done. Remember that Planning data is actually stored in Essbase so the Knowledge module you will need to use is LKM Essbase to SQL (DATA)

Maybe you are looking for

  • Dell XPS Touchpad Driver No Longer Working in Build 10041. Was fine with Build 9926

    First of this is an old Dell, but from Vista through to Windows 8.1 Update, and then the initial Windows 10 Tech Preview Builds the Mouse Drivers have been OK. Its not so much the core mouse driver, but the feature extensions in the Accompanying driv

  • Crashes and disappears!

    Hello Im new to this...put my sony cam corder using firewire, to transfer mini DV tapes image/sound comes through and saved into clips. When I click on clip to move it the program crashes and dissapears! tried re-instaling same error. Tried for hours

  • How to get the Multiplied value between measure and a dimension base on user selection using dynamically

    Hi Experts, We had developed a cube with the Measures and Dimensions. I had a requirment as the measures should be muliplied by the currency value of different countries and get me the results. For Example. In SSRS report, the user will select "EUR"

  • What's new in Premiere Elements 10?

    Version 10 of Premiere Elements includes a number of great improvements in performance and stability, including faster project opening, quicker, more responsive performance and better handling of high-def and AVCHD footage. In addition, the program i

  • Slow Internet throughput - solutions needs osx progamming fix .plists

    Below post on CNET was useful. The very last last thing worked for me. I think apple should create an AUTO refresh on some of these plists that become corrupted. It seems to be a big problems for a lot of software bottlenecks. OSX Programmers are you