Regarding dates query

i have table which contains dates in format like yyyy-mm-dd but some of dates are only
yyyy-mm and yyyy so i need a query for finding dates which are not belongs to this format.query should give result like that other than my format like yyyy-mm-dd

Hi,
As the others have said, all Oracle DATEs are stroed in the same format, which always includes the month and day. (It always includes hours, minutes and seconds, too.)
It sounds like you have a string (such as VARCHAR2) which is supposed to represent a date. That's a very bad idea, as the others have said, and you really should change the table to use a DATE instead.
Assuming the fomatting of those strings is consistent, then you can tell which of the strings include day, whichinclude just year and month, and which include year only by looking at the LENGTH.
If you want to convert them all to DATEs, here's one way:
CASE  LENGTH (column_x)
    WHEN  10                         -- Includes year, month and day
    THEN  TO_DATE (column_x, 'YYYY-MM-DD')
    WHEN   7                         -- Includes year and month, but not day
    THEN  TO_DATE (column_x, 'YYYY-MM')          -- Day will be '01'
    WHEN   4                         -- Just year
    THEN  TRUNC ( TO_DATE (column_x, 'YYYY')     
          , 'YYYY
          )                    -- Month-day will be '01-01'
ENDThe expression above shows how you can test the LENGTH of the string.
You could get the same results this way, too:
TO_DATE ( SUBSTR ( column_x || '-01-01'
           , 1
           , 10
     , 'YYYY-MM-DD'
     )I hope this an\swers your question.
If not, post a little sample data (CREATE TABLE and INSERT statemnents) and the results you want from that data.

Similar Messages

  • Regarding a query that gives a count of a certain combination of characters

    Hi all,
           I had a query to be created that gives a count of a certain combination of characteristics from a cube.
    Say a cube has 4 characteristics , Say A, B, C, D.
    Now amongst all the records that occured in the Cube I need a report of the following A, B and be able to see the count of the number of times a combination of A B occured i.e. variations of C and D for a certain A and B.
    For example say in the cube the A B C D has the following contents
    a1,b1,c1,d1
    a1,b1,c1,d2
    a1,b1,c1,d3
    a1,b1,c2,d1
    a1,b2,c1,d1
    a1,b2,c1,d2
    a1,b2,c2,d1
    a1,b2,c2,d2
    a2,b1,c1,d1.
    the report should show
    a1,b1,4 ,where 4 is the number of combination of a1 & b1.
    a1,b2,4 ,where 4 is the number of combination of a1 & b2.
    a2,b1,1 ,where 1 is the number of combination of a2 & b1.
    i want a help from all regarding this query.
    Thanking you in advance

    If you are in BW 3.5 or SEM I'd do this with a BPS-Exit that fills a key figure 'Combination Count' with 1 for each combination. If you need any details programming a BPS exit function feel free to ask.
    If you are in BW 3.0 or 3.1 without BPS-functions or you don't want to do BPS-setup just to create a user exit I'd suggest the following.
    1. Create an ODS CCOUNT that contains A,B,C,D and a key figure COUNT.
    2. Create an export data source for your cube.
    3. Create uodate rules from your cube to the ODS and set the key figure to constant 1 (with overwrite).
    4. Load your cube data into the ODS object.
    5. Load the ODS values back into the cube.
    This could lead to problems if you have other InfoObjects in your cube like time or version where you want to filter.
    Final method would be a virtual key figure but I'd try it this way first.
    B est regards
       Dirk

  • Appropritate forum to put queries regarding data archiving

    Hi All,
    Which one is the appropriate forum to put queries regarding data archiving?
    Thanks in advance.
    Vithalprasad

    Yes you can use this forum, also there is one forum for Data Transfers.
    Regards,
    Altaf Shaikh

  • How can I use FK description in a BC4J data query component?

    Hi all,
    I am facing the following problem.
    Although I use renderers in the DataEdit component for displaying the descriptions of the FKs this is not useful for the BC4J data query components.
    How can I get the same functionality as in the dataEdit components?
    Thanks in advance,
    Aggelos

    Anfortunately,
    This is not the same when I have a DataQuery component.
    The question now becomes as following:
    How can I use FK description in a BC4J data query component?
    Thanks in advance
    Aggelos

  • Regarding dates.

    hi gurus, i have some doubt regarding dates function.
    if i enter any date of present month i wand the first date of next month.
    for example  if i enter any date in january from 01/01/2007  to 31/01/2007 i want
    first date of february. ie 01/02/2007. plz help me.
    regards
    vamsi.

    Hi
    use this coding
    data : d1 type sy-datum,
            d2 type sy-datum,
            d3 type sy-datum,
            d4(8),
            m(2),
            y(4).
    d1 = sy-datum.
    CALL FUNCTION 'BKK_GET_MONTH_LASTDAY'
      EXPORTING
        I_DATE        = d1
    IMPORTING
       E_DATE        =  d2 .
    write :   d1.
    skip 3.
    m = d2+4(2).
    y = d2+0(4).
    concatenate  y m '01' into d4  .
    d3 = d4.
    write : / d3.
    write : / d2.
    write / '***********2 month****************************'.
    d3 = d2 + 1.
    CALL FUNCTION 'BKK_GET_MONTH_LASTDAY'
      EXPORTING
        I_DATE        = d3
    IMPORTING
       E_DATE        =  d2 .
    write :/ d3,
            / d2.
    write / '**************3 month ***************************'.
    d3 = d2 + 1.
    CALL FUNCTION 'BKK_GET_MONTH_LASTDAY'
      EXPORTING
        I_DATE        = d3
    IMPORTING
       E_DATE        =  d2 .
    write :/ d3,
            / d2.

  • Regarding date types

    hi all,
    i need some information regarding date types infotype 41.
    i need to print date types in sequential manner like dar01 dar02 dar03 like upto 12 date types.
    can you please suggest me how should i print them.
    thanks,
    madhavi.

    Hi,
    Steps to create a HR Infotype:
    1) Go to Transaction PM01.
    2) Enter the custom Infotype number which you want to create (Should be a 4 digit number, start with 9).
    3) Select the 'Employee Infotype' radio button.
    4) Select the 'PS Structure Infotype'.
    5) Click on Create... A separate table maintenance window appears...
    6) Create a PS structure with all the fields you want on the Infotype
    7) Save and Activate the PS structure
    8) Go back to the initial screen of PM01.
    9) Click on 'All' push button. It takes a few moments.
    10) Click on 'Technical Characteristics'. Infotype list screen appears
    11) Click on 'Change'(pencil) button
    12) Select your Infotype and click on 'Detail' (magnifying glass) button
    13) Give 'T591A' as subtype table
    14) Give 'T591S' as subtype txt tab
    15) Give your subtype field as subtype field
    16) Save and come back to PM01 initial screen
    17) Click on 'Infotype Characteristics' ... Infotype list screen appears
    18) Click on 'Change' (pencil) button
    19) Click on 'New Entries'
    20) Enter your Infotype number and short text
    21) Here we have to set different Infotype Characteristics as per the requirement. (Better open another session with some standard Infotype's infotype characteristics screen and use as the reference to fill yours)
    22) Save your entries.
    23) Now the Infotype is created and ready to use.
    24) If you want to change the layout of the Infotype as per your requirement...
    25) In the PM01 initial screen...Select 'Screen' radio button and give 2000 as the screen name, then click on edit.
    26) In the next screen.. Select 'Layout Editor' and click 'Change'.
    27) Screen default layout appears...here you can design/modify the screen..change the attributes of the fields..etc.
    28) Save and activate. (Don't forget to 'Activate at every level)
    Subtype Creation :
    Transaction PM01 Goto Subtype Characteristics. Click on Append and then subtype. Enter the name and description of subtype on screen.
    Then goto technical Characteristics and maintain the details of subtype there. I.e name of subtype i.e. component name defined in PSnnnn. Subtype table is T591A.
    Subty.text tab is T591S and time const tab is T591A.
    See:
    http://help.sap.com/saphelp_46c/helpdata/en/4f/d5268a575e11d189270000e8322f96/content.htm
    HR related site:
    http://www.sapdevelopment.co.uk/hr/hrhome.htm
    Enhancement of Infotype
    Check the following
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/PAXX/PYINT_INFOTYP.pdf
    Infotype Enhancement overview screen
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/60a7586d-edd9-2910-68a8-8204303835a1
    with regards,
    Hema SUndara.

  • Urgent regarding Data & Task Audits Back Up

    Hi Experts
    Here my question is regarding Data Audit and Task audits in V 11.1.2.1
    -->If we take the back up of Data & Task audit tables data in to other backup_tables in same schema how this can be viewed through task audit and data audit through HFM?
    -->Whether any third part tools available to audit the tasks (DATA & TASK ) information...?
    -->Whether EPM maestro can be used here..?
    Thanks in advance
    Edited by: RajaKK on May 29, 2012 6:19 PM

    Use the Audit Extract utility bundled with HFM 11.1.2.1 to export this information periodically to a CSV file that you can view offline through any text editor, or even Excel. There is a command line feature for this as well, so you could incorporate this into a batch routine.
    For anyone attending Kaleidoscope in San Antonio, TX next month, I will present the various utilities that ship with HFM including this one. Hope to see you there!
    --Chris                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Regarding ABAP Query authorization group

    Hi Team,
    This is regarding ABAP Query!
    I have created one authorization group, for testing i have assigned my id in authorization group.
    After creation of ABAP query,standard program got generated. Now i have created one transaction code at the last for the ABAP Query.
    Now the isse is even though i have deleted my id from the authorization group. I am able to execute the query from SQ01 and with the Transaction code .
    It should not happen...i want who soever id is mapped to the transaction code ...that member should only be able to run that query, otherwise there is no use of authorization group.
    Please help me out in this case.
    Thanks & Regards,
    Anil Kumar Sahni

    Are you sure that you don't have access to that authorisation group? Execute report RSUSR002. In the 'Authorization Object 1' block inform  S_TABU_DIS in 'Auth.Object' and accept. Then inform Activity=03 and Auth.Gruop= your group.
    You will get a list of all the users which, theoretically, will be able to execute the query. If you press 'Roles' or 'Profiles' in the toolbar of the listing you will get to know why you have authorisation. May be you have the SAP_ALL profile.
    Also, one more thing to take into account: how have you created your transaction? Is it referring directly to the generated report? Then it is an error, you should execute program SAP_QUERY_CALL. Read this post: [Relate transaction to query;

  • Hierarchical Tree Data Query/Record Group Question

    I need help with Hierarchical Forms right now. I'm currently trying to implement a hierarchical tree to display the different items in different categories. I have been reading up on it for the past few days, and i do not understand a few things.
    What is the difference between a data query and record group? they seem the same to me.
    How does the XX = prior XXX work? i understand that this is what connects the parent to the child.
    How do you determine what depth the node is? its done in the record group/data query, but how do i decide what level it is dynamically?
    Thanks a lot in advance!

    Thanks! I am unable to create a table specifically for the tree because i am using tables that have been ported live and are in use. My question about levels is how do I know which depth the node is. For example, i have a category called Information Technology and a category item called Business Informatics. I want to know how to decide that the Category(information technology) is on level 1 and the Item(business informatics) is on level 2.
    Information Technology
    |_
    Business Informatics
    And i do know how the Connect By XX = prior XXX works in the data query/record group.
    Thanks for your help!

  • JSP Data Query tag and case sensistivity

    Hello,
    When using BC4J Data Query tag in JSP apps how to make queries case INSENSITIVE? I undestand that string comparison in Oracle is case sensiteve and hence my dynamic query will be also. However, I would like to do something like
    select * from bla
    where upper(attribute) = upper(string) where the string is from the JSP query form entered by user.
    rade

    Use a standard INPUT tag combined with the DataValue tag. This will allow you to control the input tag while still getting the data from a BC4J attribute.

  • How to guarantee that all events regarding Data Cache are dispatched when application is terminating? Urgent

    Hello,
    we have the phenomena that when an application is commiting a transaction and then terminating,
    often not all events regarding Data Cache are dispatched by the TCP kodo.RemoteCommitProvider.
    It seems that the JVM on termination is not waiting until RemoteCommitProvider has dispatched all events regarding Data
    Cache. In this way we sometimes loose some cache synchronization and some of our customers run into serious problems.
    Is there a way to guarantee that all Data Cache events are dispatched before the aplciation terminates
    (maybe implementing a shutdown hook?).
    best regards
    Guenther Demetz
    Wuerth-Phoenix SRL

    Hi,
    as nobody answered to my question I try to explain it more simple:
    Are the TCP-kodo.RemoteCommitProvider threads acting as user threads or as threads of type 'deamon' ?
    I hope that soon someon can answer
    best regards
    Guenther Demetz
    Wuerth-Phoenix SRL
    G.Demetz wrote:
    Hello,
    we have the phenomena that when an application is commiting a transaction and then terminating,
    often not all events regarding Data Cache are dispatched by the TCP kodo.RemoteCommitProvider.
    It seems that the JVM on termination is not waiting until RemoteCommitProvider has dispatched all events regarding Data
    Cache. In this way we sometimes loose some cache synchronization and some of our customers run into serious problems.
    Is there a way to guarantee that all Data Cache events are dispatched before the aplciation terminates
    (maybe implementing a shutdown hook?).
    best regards
    Guenther Demetz
    Wuerth-Phoenix SRL

  • Help regarding data element

    I need some help regarding data element ZEXPDT.  I used it in an infoquery that was transported to QAS and it does not exist in QAS.  I thought it might be locked in a transport, but the below screen clip says it is not locked.  It was created in 3/2014.  Thanks.

    Either trick the system, SE11, add a space at end of text desciption and save,
    Or call transport workbench (SE01, SE10) create a transport request or use an existing one, then double-click on a task, switch to modify mode, add a line with R3TR DTEL name of the data element, save, then object list, lock in request/task menu.
    Or SE80, contextual menu of data element. (other functions, write transport entry)
    Regards,
    Raymond

  • Date Query for SimpleDateFormat

    HI,
    I’m trying to create a Toplink query for Date. Toplink always generates the date query in the following format for my Oracle DB:
    1.     If I pass the value new Date() in then it generates
    to_date('2005-01-05 30368','yyyy-mm-dd sssss')
    2.     If I use SimpleDateFormat with the format “yyyy/mm/dd" it creates
    to_date('2007-07-05 0','yyyy-mm-dd sssss')
    What is the value that comes after the day (30368 and 0) in each query?
    How can I make the Toplink to generate date without the time component? Preferably if there is a way for toplink to generate the date based on the Java SimpleDateFormat that would be good.
    Thanks
    -Mani

    The DATE type in Oracle stores both a date and time. The 0/30368 is the time in seconds sssss, 0 means no time. You should not have any issue with this format, what are you trying to do?

  • Date query problem

    Hi,
    On a report I'm trying to do a date query:
    select * from table v
    where ..........
    and ( to_date(v.fecha_inicio, 'dd/mm/yyyy')
    between nvl(to_date(:P_BEGIN, 'dd/mm/yyyy'),
    to_date('01/01/0001', 'dd/mm/yyyy'))
    and nvl(to_date(:P_END, 'dd/mm/yyyy'),
    to_date('31/12/9999', 'dd/mm/yyyy')) )
    and could not get the right data (return no rows), I though it was a problem with my itmes so changed the item reference for the actual values:
    select * from table v
    where ..........
    and ( to_date(v.begin_date, 'dd/mm/yyyy')
    between nvl(to_date('01/10/2006', 'dd/mm/yyyy'),
    to_date('01/01/0001', 'dd/mm/yyyy'))
    and nvl(to_date('31/10/2006', 'dd/mm/yyyy'),
    to_date('31/12/9999', 'dd/mm/yyyy')) )
    and the result is the same.
    If change to
    and (to_char(v.fecha_inicio, 'dd/mm/yyyy')
    between nvl(to_date('01/10/2006', 'dd/mm/yyyy'), to_date('01/01/0001', 'dd/mm/yyyy') )
    and nvl(to_date('31/10/2006', 'dd/mm/yyyy'), to_date('31/12/9999', 'dd/mm/yyyy') ) )
    Sends a not a valid month error but if run the same query on sqldeveloper it works right.
    My question is why I could not get the right data on apex ?
    Thanks you

    I made the changes and is the same thing, no rows returned. If I try to evaluate between or > < is the same.
    I tried
    AND (to_char(v.fecha_inicio, 'yyyy') = '2006' )
    AND (to_char(v.fecha_inicio, 'mm') = '11' )
    And is the only thing I found that works !!!
    So I'm thinking to change my conditions so select a month and year to show. Don't think my user will be happy but for the moment ......
    Thanks

  • HFR - Data Query Optimization Settings

    hi
    In HFR, in a grid there are Data Query Optimization Settings, can you please help me on the settings property.
    Our report fetches data using lot of attributes. When we don't use MDX setting, it fetches very fast, but the alias doesn't come.
    However, when we use MDX setting, the alias comes, but the report takes lot of time to run(approx 1 min / row of data fetched)
    Can you please guide on the same.
    Thanks

    pm wrote:
    Hi ,
    I am working on below query optimization/Tuning.
    SELECT
    c_date,
    c1,
    c2,
    c3,
    c4,
    c5,
    c6
    FROM tab1
    WHERE
    ROWNUM <= &param
    AND ( c_date BETWEEN &date1 AND &date2 )
    AND c3 in (
    select c3
    from tab2
    where xxx='abc')
    ORDER BY c1, c_date;
    Note : &param,&date1 ,&date2 are parameters runtime getting from UI code .
    tab1 having huge data around 10lacs to crores. and it has range partition on c_date column and subpartiotion on c1 column.
    To get best throughput in less time, what i need to do ?
    Please do let me know steps to tune/optimize the sql query.Also which hint we can use on sql query to better results.
    Thanks in advanced.
    PMBefore you start worrying about performance tuning you should worry about the query being incorrect.
             WHERE
                 ROWNUM <= &param
                 AND   ( c_date BETWEEN &date1 AND &date2 )
                 AND c3 in (
                                             select c3
                                             from tab2
                                             where xxx='abc')
             ORDER BY c1, c_date;Presumably you want to limit the number of rows with the ROWNUM predicate AFTER the ORDER BY clause is applied.
    Please read this and learn how queries are actually processed, I can almost guarantee you this query is not doing what you think it is doing at present.
    http://www.oracle.com/technetwork/issue-archive/2006/06-sep/o56asktom-086197.html
    Cheers,

Maybe you are looking for

  • Stuck on blue screen with clouds rainbow, floated ...

    As it says. When I start Skype, it goes straight to a blue screen with blue clouds and a green rainbow at the bottom. I get no prompt to login. I have followed various guides, such as renaming login to login1, deleting login, restarting the computer,

  • Adobe Flash Player 11.8.800.94 will not install in Mac

    I am trying to install Adobe Flash Player 11.8.800.94 into my MacBook OS 10.8.4 but everytime ot gets to 50% I get an error message saying Please quit the follwong programs to continue. Safari. et my Safari is closed. I have tried closing via CMD+Q a

  • Inbound JMS adapter with MapMessage

    I'm sharing the following problem and solution with using the OEP inbound message adapter because it may be a common situation occurring to other users. Recently was using the inbound JMS adapter with its default (OEP internal) converter from JMS Map

  • 1 master 2 detailregions

    I have an idea but I can't figure out the solution to a problem. Let me explain what I'm trying to do and I'll see if anyone has an idea. I'm sure it's something easy that I'm missing. i have two mysql tables I'd like to make datasets out of to displ

  • Failed install drivers

    failed install drivers