Date to Number

I have to store year and date in a database column like 'yeardate number(6)'.
I have the year and month being passed to my procedure in a number and character strings respective.
Month's value is like 'MARCH' i.e. a string, and year value is like 2009 i.e. a number.
Now I need to convert the 'MARCH' to 03, and then store the value in the table as a number like 200903.
How should I convert the string 'MARCH' month to a number 03, concatanate it to the year 2009, so that I dont get the error 'ORA-01722: invalid number'

Nag Swamiyyee wrote:
Please dont preach. We all get into jobs where applications are already written, data models are in place, and we have live with them. Reading Thomas Kyte is easy, but to work within a given scope of already developed applications is the challenge. With due respect we all know this truth.¿Preach? I don't 'preach', I pointed you to some links that helped me a lot, others a lot and I hoped they would help you as well.
And :this is not about 'reading=easy', it's about understanding how things work.
If you'd have read, searched and understood some more, then you'd know that: "applications come and go".
Data models and applications are not static.
Its about the data.
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1545206281987#51741210713900
(sorry for yet another link)
You don't adjust the data to your application, you adjust your application to the data.
I've spent quite some time to find out/understand that.
But, if you/your superiors think that it's better to store a DATE as NUMBER datatype, feel free to do so.
But 'the scope' you're refering to can be MySQL/.NET/whatever tomorrow, and then you're out of luck. No more Oracle, but we still need the data.
Just because that query using stored as a NUMBER that should actually be a DATE, crippled the database, since it got frequently used by that application you put so much faith into, but through the years it just couldn't perform anymore. Because you treated the data wrong.
work within a given scope of already developed applications is the challenge.I sincerely wish you the best of luck.
Times change.
Versions change.
So: I'm afraid 'your dream' will be shattered within 2/5 years (unless you're into mainframe-stuff), while the data is still there and still needed. And some other application will be 'sexy' then. For a while....
I'm not preaching, I'm being realistic, since I've been through that myself as well.
It's not about preaching or reading, it's about understanding.
Now, why would I reinvent the wheel if it's already there?
Hence I share links with others, since they really helped me (and many many others).
You should not only read, but also try to understand.
Nothing is static.
Applications are certainly not.
Data is.
You should not try to squash your data into a static application.
Your application should fit your data.

Similar Messages

  • Issue with the Data Type 'Number' in Business Objects

    Hi,
    I have an Object in the Universe where the Data Type of the Object is a number. This Column pertaining to this Object has certain values in the database out of which there is a 17 Digit Value which is 00000000031101165.
    Now, when trying to retreive the same value through Business Objects it is getting rounded off to 00000000031101200 automatically when trying to view in Webi and when trying to retreive the same in Designer/Deski, it displays as 0.000000003110116E+16.
    So, I would like to know if there is any other alternative in trying to retreive the Original Value that would not round off. Also, do we have any Limitation for the Data Type Number in Business Objects? The Version we are on is XI3.1.
    Note: There are no functions that are used on this Object at the Universe Level and would not like to use any functions here.

    What is the underlying database?
    It looks like the data is considered to have two decimals, but is rounded to zero decimals.
    Only you don't see the number formatting.
    Is this a BW query?
    Is this a calculated keyfigure?
    In the query you can specify the rounding you want and it is also possible to specify it on an infoobject level.
    Check those settings...
    Hope this helps,
    Marianne
    PS. Oh, and about the formatting, you can specify a default object format in the universe and override it on the final client (WebI, Crystal)

  • Issue with field data type NUMBER(22,5) while updating field data.

    Hi,
    I have a field with data type NUMBER(22,5).
    While inserting or updating field data it should take 17 digit and after decimal point 5 digit total 22 digit.
    I set 22 for maximumLength property of messageTextInput field.
    While updating field I am getting following problems,
    1) I provide the value as 1234567890123456789012 (22 digit) and click apply button.
    then I got error message as
    Error
    मैकेनाइजड दो पहिया/तीन पहिया वाहन - Value 1234567890123460000000 exceeds the maximum allowed value (NUMERIC (22, 5))
    2)then I insert 12345678901234567.1234 (17 digit before decimal point and 4 digit after decimal point and it didn't accept 5 digit after decimal point) and click apply button.
    It insert the value as 12345678901234600 (value changed after Apply)
    The I tried with simple SQL insert statement to insert data and it successfully insert 12345678901234567.12345 value.
    Any item property I missed here to set?
    Please suggest.
    Thanks & Regards,
    Sagarika

    hi
    according to
    " then I insert 12345678901234567.1234 (17 digit before decimal point and 4 digit after decimal point and it didn't accept 5 digit after decimal point) and click apply button.
    It insert the value as 12345678901234600 (value changed after Apply)"
    this statement ,it seems that it is definitely applying round or somthing like that function in the code before inserting value in the table("try with select round(12345678901234567.1234 ) from dual u will get the same result = 123456789012345600 ") ,
    bcz u r able to insert the same directely into the table using insert statement so kindely have look on the code if something like this is not happening there.try to check code in related EOimpl class
    try to to use debugging mode ,and the 23 char problem is related to maximum lenghth of text box make it 23 it will get resolved and u will be able to enter 17 digits with 5 digits after decimal point
    thanx pratap

  • Help needed in converting date to number

    Hi,
    I am trying to execute the below query, its failing with "invalid number" error.
    select * from process_status
    where time_process > to_char('&3','yyyymmdd')
    time_process is the "number" datatype.
    Details:
    SQL> select * from process_status
    2 where time_process > to_char('&3','yyyymmdd');
    Enter value for 3: 01-MAY-09
    old 2: where time_process > to_char('&3','yyyymmdd')
    new 2: where time_process > to_char('01-MAY-09','yyyymmdd')
    where time_process > to_char('01-MAY-09','yyyymmdd')
    ERROR at line 2:
    ORA-01722: invalid number
    If I execute the below query its working fine, I am facing problem only when I pass the date explicitly to the query. Please help me on converting the date to number format.
    select * from etl_process_status
    where time_process > '20090501'
    and rownum < 3;
    Thanks

    as others have said, it would be best to have your time_process column stored as a date in oracle, if it contains dates.
    The reason for this is because if you store your dates as a number, you have removed information from Oracle that says "This is a date", so when Oracle comes to try and estimate the number of rows greater than a specific value, it can no longer guess correctly, since it's basing its guess on that column being a number.
    There are lots more numbers between '20091201' and '20091101' than there are days between 1st November and 1st December.
    By hiding the fact that your data is a date, you could throw your execution plan off and end up with sub-optimal performance.
    In short, store your data in the correct column format!

  • How to get the Data Record Number in BI 7.0?

    Hi All,
    In our requirement we need to load the Data Record Number in the DSO. I got the Request ID and Data Packet Number but not the Data Record Number.
    Does anyone has any idea?

    Hi......
    When the data is activated in DSO, it is written to the table of active data, where it is then available for reporting. Requests are sorted by the key of the DataStore object, request ID, data package ID, or data record number.
    You just load the data to the DSO.....and activate it.......it will autometically get generated.......You cannot load it from one DSO to other beacuse in this case Change log table is used........and this filed is in active table..........I think you need this fir reporting purpose.....so load it and activate the DSO......then it will be available in your active table for reporting.........because reporting is done on active table.......
    Check this link :
    http://help.sap.com/saphelp_nw04s/helpdata/en/a9/49453cabf4ef6fe10000000a114084/frameset.htm
    Hope this helps you....
    Regards,
    Debjani....
    Edited by: Debjani  Mukherjee on Sep 16, 2008 5:22 PM
    Edited by: Debjani  Mukherjee on Sep 16, 2008 5:25 PM

  • Date and number display format

    Hello all,
    I am new to Adobe Form, and I am quite unimpressed with how difficult it is to do the most simple things.
    I have managed one way or another to solve all my problems until now, but this one got me stuck.
    I have date and number fields in my form, and here is what I want to do but cannot:
    - I need these fields to be displayed using the defaults date and number settings of the SAP user who is generating the form. This one is really hard for me to figure out.
    - I need some other fields to be displayed in a specific format depending on a variable in the context of my form. I imagine this could be done using scripting, but how to change the display format of a field via scripting?
    Anyone has an idea of how that can be achieved?
    Thank you.

    Hi Thomas,
    For these kind of issues you will get many answers if you search the forum.
    If your requirement is to display the current date in the form, just drag and drop the "Current date" UI element from the Library palette -> Custom.
    If it is to get the date from SAP and display, pass date to the context node and just drag and drop the field into the form from the data view.
    Check the following wiki by Chintan. It explains some common scenarios in javascript.
    [JavaScript Part 1|http://wiki.sdn.sap.com/wiki/display/ABAP/JavaScriptforCommonScenarios-PartI]
    [JavaScript Part 2|http://wiki.sdn.sap.com/wiki/display/ABAP/JavaScriptforCommonScenarios-PartII]
    Use an 'if' condition, check the value and based on the value you can make the field hide/visible in the form.
    Hope this will help.
    Thanks & Regards,
    Sanoosh

  • Need help in date to number conversion

    Hi,
    I have a doubt in a date conversion, please help me.
    I executed the below query, its throwing "invalid number" error.
    select * from test
    where date_sid between to_number(to_char('01-05-2009','dd-mm-yyyy'),'yyyymmdd') and to_number(to_char('02-05-2009','dd-mm-yyyy'),'yyyymmdd')
    date_sid column is number datatype.
    In my above query i want to pass the date value like '12-05-2009'. If i check my table date_sid looks like yyyymmdd. So how to convert '12-05-2009' to 20090512 in my above query. Please help me.
    Thanks.

    Use to_date instead of your to_char, and to_char instead of your to_number.
    That said, that's very very sad to work on date as number format.
    Nicolas.

  • Date to number conversion?

    I want to select a number of rows created within last week.
    To do it I use a select statement with:
    WHERE sysdate-o.created_on <= days;
    (days is a number, created_on is a date)
    Everything works fine, but I get warnings like this one:
    PLW-07204: conversion away from column type may result in sub-optimal query plan
    I suppose I should convert date to number to get rid of them. How can I do it isnide a SELECT query?

    While the comments regarding re-writting the query to allow the possibility of index usage are valid, the warning will still appear even with the re-written query. I am sure that this query would use an index on dt1 if one was available.
    SQL>CREATE TABLE t (id number, dt1 date, dt2 date);
    Table created.
    SQL> CREATE PROCEDURE p1 AS
      2  BEGIN
      3     FOR r IN (SELECT * FROM t
      4               WHERE dt1 = sysdate - 7) LOOP
      5        NULL;
      6     END LOOP;
      7  END;
      8  /
    SQL>/
    SP2-0804: Procedure created with compilation warnings
    SQL>show error
    Errors for PROCEDURE P1:
    LINE/COL ERROR
    3/13     PLW-07204: conversion away from column type may result in
             sub-optimal query planThe warning in this case is clearly spurious, and the reason is, at the level the compiler is looking, they are different data types. dt1 was inserted as sysdate a few minutes before I did the dunp below.
    SQL> SELECT DUMP(dt1) tab_date, DUMP(dt1 - 3) calc_date,
      2         DUMP(sysdate) sys_date
      3  FROM t;
    TAB_DATE                            CALC_DATE                          SYS_DATE
    Typ=12 Len=7: 120,107,2,27,10,45,42 Typ=13 Len=8: 7,215,2,24,9,44,41,0  Typ=13 Len=8: 7,215,2,27,9,49,13,0A date field in a table is a type 12 while sysdate, and any date that has is a result of a calculation is a type 13. Clearly a "different" datatype.
    Practically speaking, in the SQL engine, the type 13 date would be cast to a type 12 date and used in an index probe, but the compiler is likely doing something similar to the DUMP conparision.
    I believe that the type 13 dates are a representation of the C time_t struct that Oracle's kernel would likely use internally.
    John

  • Loading unpacked Zoned data into NUMBER data types

    I need to use SQL*Loader to load data created on an MVS machine (EBCDIC) which is FTP'd to AIX (converted to ASCII during the FTP). Some of the data elements have signed unpacked numeric data. These need to be loaded into two types of fields in Oracle - 1) defined as data type NUMBER(19) 2) - defined as data type NUMBER (38,2) (i.e. dollar field with 2 decimal positions). For the dollar data I am loading there is an implied decimal. I need to know how to code SQL*Loader statements to handle these two situations. Because I have zoned unpacked source the resulting data loaded into the table must have a trailing sign (only if negative). Also the dollar fields need to have an explicit decimal inserted - and these dollar fields could also end up being negative.
    Any help would be appreciated. Various google searches have not given me the answers I need.

    979755 wrote:
    Most helpful. Pardon a few follow-on questions:
    1. The Zoned definition refers (I hope) to the data on the input file - regardless of the definition of the field field being loaded in the table (in my case the field in the table is defined as NUMBER) - is this a true statement?
    True, in your controlfile you set (for example): , zonedCol POSITION(x:y) ZONED(precision,scale)
    2. If I am correct on item 1, if I have a negative number in the input file (let's say a negative 10) is a trailing sign loaded into the database (so it will be 10-)?
    NO, to deal with signed numbers, you set trailing signs as table column in a staging table and then apply to real table.
    3. What happens to any leading zeroes when the data is loaded into the table?
    Ignored.
    4. For dollar fields where the source has an implied decimal but I want an implicit decimal in loaded into the table and the number can be positive or negative, can I specify this as ZONED (10.2) in the control file?
    See answer #2.
    ZONED (10,2) implies field is 10 characters long and the last two are decimals.
    5. And finally, regarding item 4 my understanding is that ZONED (10.2) would result in 12345678.12 (with a negative sign if appropriate) - is this a correct understanding?
    Nope, only the digits. That is why we use staging table to capture the sign.
    PS: The best would be to create external table on the source file.
    Edited by: L-MachineGun on Jan 4, 2013 3:12 PM

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

  • Calculate end date from inputs : start date and number of months

    Hello Experts,
    I have a start date and number of months from which i need to calculate the end date.
    For Eg: start date = 03-12-2008
                no. of months = 48
          Ans: end date = 03-12-2012
    Please help me.

    requirement is no different from what is stated in the previous thread.
    To elaborate further, I'm looking for some Function Module or some relevant alternative to calculate the future date.
    Future date is calculated using a start date input and No. of months.
    As stated in the example in my previous thread.
    For eg:
    Inputs to FM    : Start date        : 03-12-2008
                                    No. Of months : 48  months
    Output from FM: Future Date     : 03-12-2012
    Looking forward for your reply.

  • How to convert date to number

    Hai
    How to convert the given date into number.
    Thanks & regards
    srikkanth.M

    Look at these posts
    Please help me in Converting Lilian Format to Date
    converstion to date
    and try something like this.
    SELECT sysdate,sysdate-to_date('15-10-1582','DD-MM-YYYY') lilian_dt FROM dual;

  • Gr date and number

    Hi
    I would like to know from where can i get the GR number and GR date from R/3 to BW.
    We need to create a report with the following fields
    PO number, item no, po date, GR date, GR number , ord qty, gr qty, gr val.
    In purchasing cube we dont get gr date and value.
    How do i acheive this?
    Regards
    Annie

    Hi Annie,
    I think you have to go with inventory flow instead of purchasing one...
    in 2LIS_03_BF you can find:
    EBELN (PO no.)
    EBELP (PO item)
    BWGEO (Purchase Value in Local Currency)
    and clearly everything is related to GR (date, qty and value)...
    About PO date I think you have to go for an enhancement (it would be an easy task since you already have all the key to access on EKKO table, or, if you prefer, directly in an ODS with purchasing data, if you already have something similar in BW...)
    Hope it helps!
    Bye,
    Roberto

  • Compare date to number

    Hi, I am working with the following SQL statement and can't seem to get the syntax correct:
    idSelectQuery=Select "numberprgn" from "SMT1"."CM3R1M1" where "category" != 'KM Document' AND ("sysmodtime" - TO_DATE('1970-01-01', 'YYYY-MM-DD')) * 86400000 > ?
    Where the '?' is the current system time as a number - which is actually epoch time.
    This statement fails because of: ORA-00932: inconsistent datatypes: expected NUMBER got DATE
    I need to be able to compare the sysmodtime to the ? time value, although I can't figure out a way to properly do this... I'm not sure if i can cast sysmodtime to char then to number, because I know its not possible to cast date to number directly.
    Anyone have any suggestions to get this to work?
    Thanks

    i.e TO_DATE('1970-01-01', 'YYYY-MM-DD')) * 86400000 will convert GMT to Central time.I disagree.
    when arithmetic operations are done against DATE datatype the basic Unit of Measure is DAY
    SYSDATE+1 = tomorrow!
    the result of multiplication in top line above results in some day far, FAR, FAR into the future.
    I suggest you convert epoch time value into Oracle DATE datatype for direct comparison.
    BTW, exactly from where is epoch time obtained to become part of SELECT statement?
    Re: How to convert Epoch time to Datetime (YYYYMMDDHH24MMSS)
    Edited by: sb92075 on Apr 27, 2011 12:18 PM

  • A question about date and number formats

    Hi,
    I have to change date and number formats from USA to UK format. Is the only place I must do that in user settings (SU01) ? I mean, is this enough or are there any other customizing settings, in FI for example ?
    Thanks in advance,
    Paulo

    I tested very much and the only place we should set it is on user settings

Maybe you are looking for

  • Memory overloaded?

    I've recently installed the new version of 7.1 (but this may be a red herring as I had a previous version of iTunes 7.-something) with Windows XP. iTunes is not working properly - the mouse is very unresponsive, "sticks", won't play, you have to clic

  • Reports6i:Developing reports of different size(Pre-Printed Stationary)

    I am using Reports 6i. I want to generate reports of page size 3.5" (height), 11.5"(width). I modified the layout sections width and height properties. I am printing reports on continuous Pre-printed stationary with dot matrix printer. After printing

  • Transaction code which using method of a class as start object

    Hi all, I'm creating a new tcode 'Z123' which is tied to a method of a class in SE93. However, when I run this tcode and into debug mode, SY-TCODE will always return OS_APPLICATION. How can I get the actual tcode, which is 'Z123' into my program? Tha

  • Call Color change in FLASH CS6

    I have a Flash file. I'm working on this demo project where I want to customize the color of the panels according to the thumbnails when clicked on them. The colors of the front floor must change accordingly to the color respective to the thumbnail a

  • Syncing to Itunes problem

    Whenever I attempt to sync my iPod Touch to my iTunes account I get an error message that reads: This iPod cannot be used because the Apple Mobile Device service is not started. What do i do to fix this?