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

Similar Messages

  • 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')

  • Not able to convert string attribute to number and date please help me out

    not able to convert string attribute to number and date attribute. While using string to date conversion it shows result as failure.As I am reading from a text file. please help me out

    Hi,
    You need to provide an example value that's failing and the date formats in the reference data you're using. It's more than likely you don't have the correct format in your ref data.
    regards,
    Nick

  • How to convert number datatype to raw datatype for use in data warehouse?

    I am picking up the work of another grad student who assembled the initial data for a data warehouse, mapped out a dimensional dw and then created then initial fact and dimension tables. I am using oracle enterprise 11gR2. The student was new to oracle and used datatypes of NUMBER (without a length - defaulting to number(38) for dimension keys. The dw has 1 fact table and about 20 dimension tables at this point.
    Before refining the dw further, I have to translate all these dimension tables and convert all columns of Number and Number(n) (where n=1-38) to raw datatype with a length. The goal is to compact the size of the dw database significantly. With only a few exceptions every number column is a dimension key or attribute.
    The entire dw db is now sitting in a datapump dmp file. this has to be imported to the db instance and then somehow converted so all occurrences of a number datatype into raw datatypes. BTW, there are other datatypes present such as varchar2 and date.
    I discovered that datapump cannot convert number to raw in an import or export, so the instance tables once loaded using impdp will be the starting point.
    I found there is a utl_raw package delivered with oracle to facilitate using the raw datatype. This has a numbertoraw function. Never used it and am unsure how to incorporate this in the table conversions. I also hope to use OWB capabilities at some point but I have never used it and only know that it has a lot of analytical capabilities. As a preliminary step I have done partial imports and determined the max length of every number column so I can alter the present schema number columns tp be an apporpriate max length for each column in each table.
    Right now I am not sure what the next step is. Any suggestions for the data conversion steps would be appreciated.

    Hi there,
    The post about "Convert Numbers" might help in your case. You might also interested in "Anydata cast" or transformations.
    Thanks,

  • Convert number of dayes per year to data

    Please i need help in Convert number of dayes to date
    I have ID's like id
    FT*09025*0000000001 date=20090125
    FT*01171*0000000002 date=20100620
    so should convert first five number after FT to date
    example *09025*
    09 map to 2009
    025 number of dayes per year map to 25 jan
    example *01171*
    01 map to 2010
    171 number of dayes per year map to 20 jun
    (jan+feb+mar+apr+may)=(31+28+31+30+31)=151
    171-151=20 for the next month
    Please need help so will added filter to informatica map with date
    Edited by: user8929623 on Jul 4, 2010 7:04 PM

    Well, I do not follow why when 09 maps into 2009, 01 maps into 2010, not into 2001. Assuming it should be 2001, use YYDDD format:
    SQL> with t as (
      2             select 'FT*09025*0000000001' id from dual union all
      3             select 'FT*01171*0000000002' from dual
      4            )
      5  select  to_date(substr(id,4,5),'yyddd') dt
      6    from  t
      7  /
    DT
    20090125
    20010620
    SQL> SY.

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

  • How to add date with month after convert number to month?

    How to add date with month after convert number to month?
    Month Date Result
    24 21/11/09 24*(21/11/09)
    I want to add both the column and result should be 21/11/11
    Thanks
    Nihar

    Hmm,
    Because, you are using YYYY for '09'.
    SQL> ed
    Wrote file afiedt.buf
      1* select to_char(to_date('10/01/09','DD/MM/RRRR'),'DD/MM/YYYY') from dual
    SQL> /
    TO_CHAR(TO
    10/01/2009
    SQL> ed
    Wrote file afiedt.buf
      1* select to_char(to_date('10/01/09','DD/MM/YYYY'),'DD/MM/YYYY') from dual
    SQL> /
    TO_CHAR(TO
    10/01/0009Or with Add_months
    SQL> ed
    Wrote file afiedt.buf
      1* select to_char(add_months(to_date('10/01/09','DD/MM/YYYY'),36),'DD/MM/YYYY') from dual
    SQL> /
    TO_CHAR(AD
    10/01/0012
    SQL> ed
    Wrote file afiedt.buf
      1* select to_char(add_months(to_date('10/01/09','DD/MM/RRRR'),36),'DD/MM/YYYY') from dual
    SQL> /
    TO_CHAR(AD
    10/01/2012-Arun

  • Convert Number to the date format

    Hello,
    In CRM, i want to input the number as a parameter and convert the number into Date format. Is there any function module in CRM which accepts the number and gives the date as output .
    Example.
    suppose input given is 734484
    output : 12-12-2011  .
    The number  734484 reflects  the total number of days from '0000' to 12-12-2011
    Regards,
    Rohini

    920575 wrote:
    I have a sql like this:
    select to_date('MAR','Mon', 'NLS_DATE_LANGUAGE=American') m from dualI want to display '3' instead of showing MAR...
    I tried to use to_char(date,'MM') but the result will return '03'.
    I would like to have the output exactly equal to 3.3 (without single-quotes) is a NUMBER. It is exactly equal to the NUMBER 03.
    '3' is a string. It is not equalt to the string '03'.
    Do you want a NUMBER or a string?
    If you want the 1-character string '3', then use 'fmMM' instead of 'MM'.
    select  TO_CHAR ( to_date ('MAR', 'Mon', 'NLS_DATE_LANGUAGE=American')
                    , 'FMMM'
                    )   AS m
    from    dualTO_CHAR sometimes adds padding (sometimes spaces, sometimes '0's) to make elements a constant width. For example, some months need 2 characters for the 'MM' format, so TO_CHAR, by default, left-pads with '0's to make all months 2 characters, whether they need 2 characters or not. Using 'FM' (case insensitive) IN the format string changes whether or not this kind of padding will be added.
    You could also use LTRIM to remove the leading '0's in this case, but why remove them when it's easier not to generate them in the first place?

  • Convert String to Date and Format the Date Expression in SSRS

    Hi,
    I have a parameter used to select a month and year  string that looks like:    jun-2013
    I can convert it to a date, but what I want to do is,  when a user selects a particular month-year  (let's say "jun-2013")
    I  populate one text box with the date the user selected , and (the challenge Im having is)  I want to populate a text box next to the first text box with the month-year  2 months ahead.    So if the user selects 
    jun-2013   textbox A will show  jun-2013 
    and textbox B will show  aug-2013..
    I have tried:
    =Format(Format(CDate(Parameters!month.Value  ),  
    "MM-YYYY"  )+ 2  )   -- But this gives an error
    This returns the month in number format   like "8"    for august...
    =Format(Format(CDate(Parameters!month.Value  ), 
    "MM"  )+ 2  )
    What is the proper syntax to give me the result    in this format =  "aug-2013"  ???
    Thanks in advance.
    MC
    M Collier

    You can convert a string that represents a date to a date object using the util.scand JavaScript method, and then format a date object to a string representation using the util.printd method. For more information, see:
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1254.html
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1251.html
    In your case, the code would be something like:
    var sDate = "2013-01-10";
    // Convert string to date
    var oDate = util.scand("yyyy-mm-dd", sDate);
    // Convert date to new string
    var sDate2 = util.printd("mm/dd/yyyy", oDate);
    // Set a field value
    getField("date2").value = sDate2;
    The exact code you'd use depends on where you place the script and where you're getting the original date string, but this should get you started.

  • Converting hexadecimal XML data to a string

    Hello!
    Until now I generated XML data with the FM 'SDIXML_DOM_TO_XML'.
    After that I did a loop over the xml_as_table in which I was casting each line of that table to a string.
    ASSIGN <line> TO <line_c> CASTING.
    After the inftroduction of unicode in our system I get a error:
    In the current program an error occured when setting the field symbol <LINE_C> with ASSIGN or ASSIGNING (maybe in combination with the CASTING addition).
    When converting the base entry of the field symbol <LINE_C> (number in base table: 32776), it was found that the target type requests a memory alignment of 2
    What does it mean? Does somebody have a solution.
    I need this function for sending this XML data as string over a simple old CPIC connection.
    Best regards
    Martin

    Hello Martin
    Perhaps my sample report ZUS_SDN_XML_XSTRING_TO_STRING provides a solution for your problem.
    *& Report  ZUS_SDN_XML_XSTRING_TO_STRING
    *& Thread: Converting hexadecimal XML data to a string
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1029652"></a>
    REPORT  zus_sdn_xml_xstring_to_string.
    *-- data
    *-- read the XML document from the frontend machine
    TYPES: BEGIN OF xml_line,
            data(256) TYPE x,
          END OF xml_line.
    DATA: xml_table TYPE TABLE OF xml_line.
    DATA: go_xml_doc       TYPE REF TO cl_xml_document,
          gd_xml_string    TYPE string,
          gd_rc            TYPE i.
    PARAMETERS:
      p_file  TYPE localfile  DEFAULT 'C:payload_idoc.xml'.
    START-OF-SELECTION.
      CREATE OBJECT go_xml_doc.
      " Load XML file from PC and get XML itab
      CALL METHOD go_xml_doc->import_from_file
        EXPORTING
          filename = p_file
        RECEIVING
          retcode  = gd_rc.
      CALL METHOD go_xml_doc->get_as_table
        IMPORTING
          table   = xml_table
    *      size    =
    *      retcode =
    " NOTE: simulate creation of XML itab
      go_xml_doc->display( ).
      create object go_xml_doc.
      CALL METHOD go_xml_doc->parse_table
        EXPORTING
          table   = xml_table
    *      size    = 0
        receiving
          retcode = gd_rc.
      CALL METHOD go_xml_doc->render_2_string
    *    EXPORTING
    *      pretty_print = 'X'
        IMPORTING
          retcode      = gd_rc
          stream       = gd_xml_string
    *      size         =
      write: / gd_xml_string.
    END-OF-SELECTION.
    Regards
      Uwe

  • Convert to a date error

    i have a the code below which i am passing a form value to
    <CFLOCATION
    url="CalendarCurrent.cfm?DATE=<cfoutput>#form.Diary_Date#</cfoutput>">
    but i am getting cannot convert to a date error, i cannot
    change the code below as other pages use it, so how can i change
    the cflocation date to match.
    i have tried dateformat and lsdateformat any ideas?
    <cfif NOT IsDefined("URL.DATE")>
    <cfset session.DATE= DateFormat(Now(), "dddd DD MMMM
    yyyy")>
    <cfset session.SHORTDATE= DateFormat(Now(),
    "yyyy-mm-dd")>
    <cfelse>
    <cfset session.DATE= (DateFormat(URL.DATE, "dddd DD MMMM
    yyyy")) >
    <cfset session.SHORTDATE= (DateFormat(URL.DATE,
    "yyyy-mm-dd")) >
    </cfif>

    Hi,
    You didnt understand some basic stuff, so i tell you what you
    should have done:
    "The value "27/3/2007" could not be converted to a date."
    <cfset myDate="form.Diary_Date">
    this line you create myDate parameter with value from form,
    Diary_Date field.
    you should use # signs because coldfusion doesnt know
    otherwise you want to use cf parameters value.
    in other words otherwise you are telling coldfusion that
    mydate is string containing literaly "form..Diary_Date".
    take care you always trim parameter values from forms, same
    browsers are so nice to adding extra enter character at end of
    field value. so first line goes:
    <cfset myDate="#Trim(form.Diary_Date)#">
    now, sence myDate parameter is fine, lets focus few minutes
    how you split value from myDate to tree different pieces.
    GetToken fuction is nice fellow when you want split
    preformated string to pieces, preformated mean that string always
    look same kind. just like dates. year, month and day are in same
    positions at string, while year might be different.
    example: 1.1.2007 and 1.1.2003, get it?
    usage of gettoken is very simple, you just tell function
    first parameter where he has to split you piece of string and
    second
    you tell number of piece to look for and last you tell what
    character is separator of each piece.
    so, since date you want to process is "27/3/2007", date is
    first, month next and year last.
    separator is "/" so, getting month should be like this:
    myDate is parameter is strinng to be splitted.
    number 2 is order number, month is second piece at string
    / is piece separator.
    Following code will give you substring "3" from string
    "27/3/2007".
    <cfset myDate_Month = "#GetToken(myDate,2,"/")#">
    Can you repair your self next two lines?
    <cfset myDate_Day = "#GetToken(myDate,1,"\")#">
    <cfset myDate_Year = "#GetToken(myDate,3,"\")#">
    Cheers
    Kim

  • Function module for converting number to exponential???

    Hi All
      please tell me Function module for converting number to exponential.
    Deepak

    try:
    REPORT Zconvertf.
    parameters p1 type p decimals 2 default '4711.99'.
    data f1 type f.
    move p1 to f1.
    write: / p1, f1.
    hope that helps
    Andreas

  • Number to date and date to number??

    select substr(to_char((to_date('1970-01-01 03:00:00','yyyy-mm-dd hh24:mi:ss')+TIMESTAMP/86400000),'yyyy-mm-dd hh24:mi:ss'),1,19) from table where rownum<2;
    Result :2006-10-03 19:25:07
    but without conversion
    select timestamp from table where rownum<2;
    Result:1159892707453
    Suppose i have value as date like 2006-10-03 19:25:07
    I need to convert to number 1159892707453
    Please note I have used standard webmethod conversion for number to date, But my developer who want know the conversion of date format to number format as mentioned above.
    could you help on this
    Thanks
    Raj

    For the number to date conversion you may find the following helpful. It works with daylight savings also - not sure if it is an issue for your region. You can get the timezone names from V$TIMEZONE_NAMES;
    SQL> SELECT
       CAST((TIMESTAMP '1970-01-01 00:00:00 GMT' + NUMTODSINTERVAL(1159892707453/1000, 'SECOND')) AT TIME ZONE 'Indian/Mayotte' AS DATE) ora_dt
    FROM dual
    ORA_DT             
    2006-10-03 19:25:07

  • Converting varchar2 to date format

    I've converted date formats many times, but for some reason I'm getting an invalid number error when trying to convert a varchar2 column. I've tried the to_char and to_date function and I get the same result. The column is a date and it is formatted as DD-MON-YYYY, but I want to change it to MM/DD/YYYY. My query is below:
    select to_date('fccpdate','MM/DD/YYYY')
    from cc_class_scmast_v
    When I try to_date I get this:
    Error starting at line 1 in command:
    select TO_DATE('fccpdate', 'DD-MON-YYYY') from cc_class_scmast_v where fccpdate IS NOT NULL
    Error report:
    SQL Error: ORA-01858: a non-numeric character was found where a numeric was expected
    01858. 00000 - "a non-numeric character was found where a numeric was expected"
    *Cause:    The input data to be converted using a date format model was
    incorrect. The input data did not contain a number where a number was
    required by the format model.
    *Action:   Fix the input data or the date format model to make sure the
    elements match in number and type. Then retry the operation.
    When I try to_char I get this:
    Error starting at line 1 in command:
    select TO_char('fccpdate', 'DD-MON-YYYY') from cc_class_scmast_v where fccpdate IS NOT NULL
    Error report:
    SQL Error: ORA-01722: invalid number
    01722. 00000 - "invalid number"
    *Cause:   
    *Action:
    I've tried removing the single quotes from my column and that doesn't make a difference. Any help is appreciated.

    Hi,
    housetiger77 wrote:
    I've converted date formats many times, but for some reason I'm getting an invalid number error when trying to convert a varchar2 column. I've tried the to_char and to_date function and I get the same result. The column is a date and it is formatted as DD-MON-YYYY,If the column is a DATE, then it has the same format that all DATEs have, which is nothing like 'DD-MON-YYYY'. Formats like that only apply to strings.
    Conversely, if it is formatted as 'DD-MON-YYY', then it is a string, not a DATE.
    but I want to change it to MM/DD/YYYY. My query is below:
    select to_date('fccpdate','MM/DD/YYYY')
    from cc_class_scmast_vTO_DATE (x, 'MM/DD/YYYY') tries to convert the string x into a DATE. Let's say it starts by taking the first 2 characters of x, to get the month. The first 2 charcters of 'fccpdate' are 'fc', which is not a valid number (at least not in base 10), let alone a number between 1 and 12, so TO_DATE raises an error.
    When I try to_date I get this:
    Error starting at line 1 in command:
    select TO_DATE('fccpdate', 'DD-MON-YYYY') from cc_class_scmast_v where fccpdate IS NOT NULL
    Error report:
    SQL Error: ORA-01858: a non-numeric character was found where a numeric was expected
    01858. 00000 - "a non-numeric character was found where a numeric was expected"
    *Cause:    The input data to be converted using a date format model was
    incorrect. The input data did not contain a number where a number was
    required by the format model.
    *Action:   Fix the input data or the date format model to make sure the
    elements match in number and type. Then retry the operation.
    When I try to_char I get this:
    Error starting at line 1 in command:
    select TO_char('fccpdate', 'DD-MON-YYYY') from cc_class_scmast_v where fccpdate IS NOT NULL
    Error report:
    SQL Error: ORA-01722: invalid number
    01722. 00000 - "invalid number"
    *Cause:   
    *Action:
    I've tried removing the single quotes from my column and that doesn't make a difference. Any help is appreciated.That's a good first step. Literals are enclosed in single-quotes, identifiers (including column names) are not. 'fccpdate' is the literal 8-character string containing 'f', 'c;, another 'c', 'p', 'd', 'a', 't' and 'e'. fccpdate (without single-quotes) can be the name of a column.
    If fccpdate is a string, such as '18-JUL-2012', then you can convert it to a DATE using TO_DATE.
    TO_DATE (fccpdate, 'DD-MON-YYYY')If you want to display a DATE in a particular format, use
    TO_CHAR ( d
            , f
            )where d is a DATE, and f is the format string. In this case, d might be the TO_DATE expression above
    TO_CHAR ( TO_DATE (fccpdate, 'DD-MON-YYYY')
            , 'MM/DD/YYYY'
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.
    See the forum FAQ {message:id=9360002}

  • 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

Maybe you are looking for

  • Best Practice - WAP connecting switchport configuration.

    Is there a best practice for deploying the WAP's in a WAP/WLC infrastructure?  Should the connecting switchport be an Access port or a Trunk port?  I've seen this implemented in both fashions and wasn't sure if one was a better choice than the order.

  • How can i get rid of this problem ?

    Exit Code: 6 Please see specific errors and warnings below for troubleshooting. For example,  ERROR: DW050 ... WARNING: DF012 ...   -------------------------------------- Summary --------------------------------------  - 0 fatal error(s), 20 error(s)

  • Photosmart7150 print issue with iMac

    Printer is installed on Win7 machine and networked through ethernet connection. Whenever I print from the iMac the file expands from a few hundred kilobytes to several megabytes by the time it shows up on the Win machine spooler. The print job then r

  • In the dvd player, the button to go back chapters does not work!

    Hi.. I need some help please. In the dvd player when I ask to skip a chapter, the command works fine, however when I ask to return to the previous chapter it back to the beginning of the same chapter. And only works if I press the back button twice q

  • Opening a new window from navigation bar?

    I want one of my navigation bar links to open in a new window. There doesn't seem to be a place where i can specify the target="_blank" attribute so I've tried using javascript. If I enter: "javascript:window.open('URL HERE', 'WINDOW NAME HERE', 'loc