Convert from NUMBER to DATE

I have data in one table that has the columns DAY,MONTH,YEAR in datatype NUMBER. I am wanting to convert that to DATE datatype and concate the month,day, and year. Can someone help me please? Thanks
SELECT TO_DATE(month||day||year,'MM/DD/YYYY')
FROM DATA_TABLE;

Hi,
Unfortunately, TO_DATE doesn't accept NUMBERs as arguments. You have to convert them to characters first, like this:
SELECT  TO_DATE ( TO_CHAR (month, '00') ||
                  TO_CHAR (day,   '00') ||
                  TO_CHAR (year,  '0000)     -- not '00', as originally posted
                , ' MM DD YYYY'
FROM  DATA_TABLE;Edited by: Frank Kulash on Jan 15, 2009 10:18 AM
This assumed the full year was stored, e.g. 2009. It turns out that OP is actually storing only the last two digits, which caused ORA-01841 errors. In that case
code}
SELECT TO_DATE ( TO_CHAR (month, '00') ||
TO_CHAR (day, '00') ||
TO_CHAR (year, '00)
, ' MM DD RR'
FROM DATA_TABLE;
is correct.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Cannot convert from java.util.Date to java.sql.Date

    In the below code am trying to get the current date and 60 days prior date:
    Date  todayDate;
              Date  Sixtydaysprior;
              String DATE_FORMAT = "MM/dd/yy";
              DateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
             Calendar cal = Calendar.getInstance();
              todayDate = sdf.parse(sdf.format(cal.getTime()));
              cal.add(Calendar.DATE, -60);
             Sixtydaysprior = sdf.parse(sdf.format(cal.getTime()));I have imported following files:
    <%@page
         import="java.util.Calendar,
                   java.text.SimpleDateFormat,
                   java.text.ParseException,
                            java.util.*"
    %>Shows up following error msg:
    Type mismatch: cannot convert from java.util.Date to java.sql.Date
    Thanks.
    Edited by: MiltonDetroja on May 22, 2009 11:03 AM

    Shows up following error msg:
    Type mismatch: cannot convert from java.util.Date to java.sql.Date
    I don't think this exception is thrown from the portion of code you have shown. As clearly specified in exception message, you cannot cast an instance of java.util.Date to java.sql.Date. you will need to do something like this
    java.util.Date today = new java.util.Date();
    long t = today.getTime();
    java.sql.Date dt = new java.sql.Date(t);

  • How can I convert from Modbus raw data to engineering units using a formula?

    Within Lookout, I have several Modbus numerical input types that do not have a linear corespondence to the Engineering values they represent.  How can I display these values accurately using a formula to convert from the raw data to an engineering value?

    I don't quite understand your reply.  I'm using Lookout 6.0.2, logged in as Administrator, in Edit Mode.  The Modbus object is named RTU06_SAV.  The Active member is 30002 with an alias of SAVfmSMT_RSL.
    Following your instructions, I opened Object Explorer and right-clicked on RTU06_SAV. 
    This opened a menu containing:  Refresh, Cut, Copy, Rename, Delete, Edit connections..., Edit Data Member Configuration, Configure Network Security and Properties.
    I assumed that I should select Edit Data Member Configuration, but maybe I'm wrong. 
    Within Data Member Configuration I can set up Linear Scaling between Raw data and Engineering data.  I know how to do that, but what I need to know is how to convert Raw data to Engineering data using a formula representing a non-linear transformation (such as a converion to a logarithmic value or perhaps a formula derived by fitting the formula to a curve on a calibration chart).
    Once I have this my Engineering data can be represented on a control panel as both a numeric value AND as a correctly reading Gauge.  It can also be properly represented on a HyperTrend graph.
    What do you suggest?

  • How to convert from line chart data to CSV format

    Hi ,
    I am using Flex 3 and AS.
    I am getting data from MS SQL and display the data as line
    chart this is ok.
    But i want to convert this line chart data to CSV or .xsl
    format.I find one example in fourms the from data grid to CSV
    For this URL is
    http://www.abdulqabiz.com/blog/archives/flash_and_actionscript/datagriddataexporter.php
    But i want Line chart to CSV.Please help me.

    Line chart is a just a visual representation of some data
    that's sitting in your database. Isn't it? You load this in Flex,
    probably using HTTPService class, and pass it to some chart object.
    Now when use says that she needs it in CSV format, you're
    gonna have to send another request to the server to produce the
    same data, convert into CSV or XLS format and let user download it.
    Of course, if use doesn't want to download, you don't have to
    go to the server, at least for CSV format. You can convert the same
    data that used plot the chart to convert to CSV.
    Am I missing something here?
    ATTA

  • Convert from timestamp to date in a table

    Hi All,
    I have a table in oracle 10g r2.
    I want to convert from time-stamp to date in a column of my table.
    The table contain 10 million records.Please help me out with the easiest way to proceed.
    Thanks in advance
    USR0072

    Add a date column to the table
    run an UPDATE statement to update the date column from the timestamp column
    mark the timestamp column unused (or drop the column)

  • Convert from String to Date for storing in SQL Server 2000

    Hi,
    I've accepted some values from a user using a form in HTML.Now using Servlets I transfer the value to my java code .
    I want to know how can I convert a DATE accepted from the user thats presently in "String" format to the "datetime" format for SQL Server2000.
    Please guide me with some steps and I shall be grateful.
    Thanks

    The java.text.SImpleDateFormat class is most probably of use.
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    String enteredDate = "25/12/2006";
    java.util.Date utilDate = sdf.parse(enteredDate);
    java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());You can then use the java.sql.Date with the "setDate()" method of a prepared statement. This method would be database independant, as you are setting an actual date, not depending on a specific format on the database end.

  • Converting from the windows date format

    Folks,
    I have no doubt this has been answered before somewhere in deep dark recesses of these forums, but I'm having trouble finding a solution...
    I have a csv file that contains a date and time field that has been stored in what I gather is a Microsoft format whereby the date and time are represented as a flaoting point number. The data can look something like 38410.25 which turns out to be 27/02/2005 06:00:00. Anyone been through this movie before?
    Thanks,
    overcanyon.

    Peter,
    From snippets I've seen about the place, the microsfot calendar started in 1 jan 1900. I'm not even gonna think about the timezone but there is leap years an' stuff to think about and I'm feeling lazy in a kinda 'this code must be done before sorta way'.
    You're making me feel guilty now. Like maybe there's not as much to it as I think.
    Nah, thinking about leap years is makin' my brain ache. Yeah, Y2K flashbacks comin' on...
    Any takers on where a ready made class might be living? :)
    overcanyon

  • Bug when converting from text to date

    Hello Guys,
    I have a table with about 700 rows and the first column is for date.
    Most rows correctly have the cell content as date, but some rows show it as text, and even when I try to change it to date, nothing happens. It sticks as text.
    Main problem is I can't sort correctly of even do calculations.
    For me it really seems to be a bug.
    The only solution I see is to create a new column to convert the values with formula, but this is a shame to need to do this to workaround such simple bug.
    Best regards,
    Bruno

    Hi Wayne,
    LOL.
    Here's the cell that came from text file exactly like the next one. After setting as date in the format panel, it stays as expected:
    The row below came from another paste from the same text file, but it insists on not becoming date:
    After setting date, and leaving the cell selection, it goes back to "Automatic".
    In the bar at the bottom, it is shown as "Text".
    I have already tried to select the entire column and set as Date, and also to do it individually, but only some are converted. Other stays as Texts.
    Best regards,
    Bruno

  • Need you help !!! -- Convertion from Char to Date

    Dear experts:
    I am new to abap and here is one thing need your help:
    Currently I have a char type field defined in the source table, after I retrive this field into my work area, I need to convert it to Date type and then calculate the last day of this date.
    for example: WA_TEST-CHAR = '20100801'. This value in orignal ECC table is char type.
    Then How can I convert this value to a date type, and calculate its last day?
    My expected result is "20100731".
    BTW, does anybody know how to convert a date type field to a number type field like To_number() or something?. If I need to get the period between 2 different date, how can I get this?
    Any post will be appreciate and thank you all in advance!
    Best Regards
    Tim
    Moderator message: sorry, date conversion and date calculation are very basic and FAQs, please search for available answers, also read ABAP online documentation.
    locked by: Thomas Zloch on Aug 23, 2010 9:56 AM

    Hi,
    For your question:
    BTW, does anybody know how to convert a date type field to a number type field like To_number() or something?. If I need to get the period between 2 different date, how can I get this?
    use this FM FIMA_DAYS_AND_MONTHS_AND_YEARS.
    regards,

  • Convert from String to Date

    Hello,
    I have the following string: "Thu Apr 22 00:00:00 IDT 2004"
    and I need to convert it to Date object.
    I tried to use Date.parse() and Date.valueOf(),
    but then I get the IllegalArgumentException.
    How can I do this?
    Thanks.

    split ur string. get year,month,day in int
    time in long
    now it will work for u
         Date d = new Date(int year,int mon,int date);//Deprecated
         d.setTime(long time); //Sets this Date object to represent a point in time that is time milliseconds after January 1, 1970 00:00:00 GMT.
         System.out.println(d);
    Ignore that answer, please and DynaFest read the API!

  • How to convert from number to currency format?

    Dear all,
    As use BPEL transformation or assign,
    I want to convert number format to currency foramt. (ex, 2000.00 -> 2,000.00)
    How to do this?
    Regards
    Toven.

    Hi Toven,
    Following XSL will Convert (123456789.80 -> 123,456,789.80)
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:decimal-format name="euro" decimal-separator="." grouping-separator=","/>
    <xsl:template match="/">
    <xsl:value-of select="format-number(123456789.80, '#,###.80', 'euro')"/>
    </xsl:template>
    </xsl:stylesheet>
    Output: 123,456,789.00
    Regards,
    KanmaniRajan

  • Convert from String data type to Character data type

    Hi...,
    I'm a beginner. I try to make a program. But I don't know how to convert from string to data type. I try to make a calculator with GUI window. And when somebody put "+" to one of the window, I just want to convert it to Character instead of String.
    Sorry of my bad english..
    Please help me....
    Thanks

    String s = "a+b";
    char theplus = s.charAt(1);

  • Number to Date conversion

    Hi, in my answers report date is displaying as 20,071,224.0 , i want to convert this number to Date format like MM-DD-YYYY, this is not a Time Dimension. do we need to convert this column in RPD or can we do it from Answers, Please help me on this.
    OBIEE 10.1.3.4.1

    i tried using to the below similar query but getting the following error
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 17001] Oracle Error code: 12801, message: ORA-12801: error signaled in parallel query server P041, instance omidrl020:DOBI1 (1) ORA-01861: literal does not match format string at OCI call OCIStmtExecute
    [nQSError: 10058] A general error has occurred. [nQSError: 22025] Function Cast is called with an incompatible type. (HY000)
    SQL Issued: SELECT "PT"."PT Description", "PT"."QTD Pay Item Amount", "PT"."YTD Pay Item Amount", "PT".PAY_ITEM_AMT, "PT".PAY_DT_WID, "PT".PAY_DT_WID, "Teammate Attributes"."Teammate Name", "Teammate Attributes"."Teammate Number", CAST("PT".PAY_DT_WID AS DATE) || '-' || CAST("PT".PAY_DT_WID AS DATE) || '-' || CAST("PT".PAY_DT_WID AS DATE), Time."Month", Time."Year" FROM
    PAY_DT_WID column type is DOUBLE in rpd, which is the type we need to use with the CAST function, Please help me

  • Convert from NVARCHAR2 to Unicode in SQL Plus

    I need to convert from NVARCHAR2 column data to Unicode format in a query. How can I do this?

    I need to convert from NVARCHAR2 column data to Unicode format in a queryMaybe with convert:
    SQL> select convert(n'ABC', 'utf8') abc from dual;
    AB

    1 row selected.?

  • Convert from date to number

    Hi,
    I want to convert from date to number. How can I do?
    Thanks
    [email protected]

    That rather depends on what sort of number you want.
    You can probably get what you want by a combination of to_char and to_number.

Maybe you are looking for

  • Class override, how to create the child class and then the base class

    I started to write a program for a smart DMM, the problem is every version of the DMM the company change the communication commend. My idea is to write a child class for every DMM version and every SubVI of the child will override the base class SubV

  • How do you NOT sync Apple TV purchases to iTunes?

    This question is on behalf of my parents who have Apple TV - which i bought for them and i have become their tech support on 24 hour call >< Background: My parents share the same account. Dad uses the PC computer with iTunes where my mother only uses

  • C:\windows\system32\deploytk.dll

    Greetings all. Is this file only found within https://jdk6.dev.java.net/6uNea.html Thank you. -Dennis Edited by: AlfredTheGrey on Nov 2, 2007 12:04 PM

  • DVR menu slows down

    Thursday morning about 01:00 EST the operating system of my FIOS DVR was replaced. The menu operation is now far slower than it was - that is, getting a program to play or stop or delete. You can tell the new OS from the background color - now black.

  • Invalid Package error (limits?) - SQL*Loader

    I seem to have reached a limit on SQL*Loader in 8.1.6 on the number of columns I am trying to load. The table has 97 columns - if I try to specify more than 92 columns I get an invalid package error - it doesn't matter which column I pick. The row wi