Date equality in select statement

Date equality in select statement giving 0 result even table contains record matching to it.please suggest what wrong in this query
1- select *from  EOE_POC.PRODUCT_TEST_REPORT where CREATE_DATE = '03-SEP-13'
2 - select *from  EOE_POC.PRODUCT_TEST_REPORT where CREATE_DATE >= '03-SEP-13'
above query (2nd one) is giving 2 records.But I am intend to check for equality not greater ..plz enlighten

Deekay wrote:
Thanks Bhushan.
select *from  EOE_POC.PRODUCT_TEST_REPORT where CREATE_DATE = sysdate
can u plz throw some more light how to check by sysdate?
Assuming CREATE_DATE is -- as it should be -- defined as a DATE (not a varchar) you need to be aware of the fact that DATEs always carry "time" as well.   So sysdate is not just "today", it is "this very second".    That's why you need to consider the use of TRUNC when you want to compare dates without consideration for the time.
The other thing you need to be aware of is that the literal '03-SEP-13' is not a DATE, but a character string that humans would tend to recognize as representing a date.  But to a computer it is still just a character string, fundamentally no different from "here's yer sign!".  Therefore, in your usage of comparing the character string '03-SEP-13' to the DATE in CREATE_DATE, oracle has to to an implicit conversion.  And to do that implicit conversion it has to know what part of the character string represents the day, the month, the year, and possibly the hour, minute, and second.  To do this, it relies on the current setting of NLS_DATE_FORMAT, which may or may not be what you expect.    Please see: http://edstevensdba.wordpress.com/2011/04/07/nls_date_format/ - But I want to store my date as ...  for a more complete explanation.
And finally, why are you using 2-digit years?  Are you actually working in IT and never heard of "the Y2K problem"?  Fifteen years ago I and thousands of my colleagues began a two-year grind of busting our butts to make sure systems continued to function correctly when the current date became 01-Jan-2000.  Please don't repeat the same mistakes that caused that problem.

Similar Messages

  • Issue with Past Month data in the Select Statement

    Hi,
    I written the following query,
    SELECT   /*+NO_MERGE(A)*/
                CASE
                   WHEN snap_shot_date > a.q3
                   AND snap_shot_date <= a.q4
                      THEN q4char
                   WHEN snap_shot_date > a.q2 AND snap_shot_date <= a.q3
                      THEN q3char
                   WHEN snap_shot_date > a.q1 AND snap_shot_date <= a.q2
                      THEN q2char
                   WHEN snap_shot_date > a.q0 AND snap_shot_date <= a.q1
                      THEN q1char              
                END snap_shot_date,
                CASE
                   WHEN snap_shot_date > a.q3 AND snap_shot_date <= a.q4
                      THEN 1
                   WHEN snap_shot_date > a.q2 AND snap_shot_date <= a.q3
                      THEN 2
                   WHEN snap_shot_date > a.q1 AND snap_shot_date <= a.q2
                      THEN 3
                   WHEN snap_shot_date > a.q0 AND snap_shot_date <= a.q1
                      THEN 4
                END sort_by,
                pillar3_exposure_class_code, pd_band_description,
                ROUND (SUM (p3.ead_post_sec_post_crm)),
                ROUND (SUM (notional_principle)),
                DECODE (SUM (notional_principle),
                        0, 0,
                        ROUND (  SUM (DECODE (exposure_type,
                                              'UNDRAW', ead_post_sec_post_crm,
                                              0
                               / SUM (notional_principle),
                               4
                DECODE (SUM (p3.ead_post_sec_post_crm),
                        0, 0,
                        ROUND (  SUM (pd_value * p3.ead_post_sec_post_crm)
                               / SUM (p3.ead_post_sec_post_crm),
                               2
                DECODE (SUM (p3.ead_post_sec_post_crm),
                        0, 0,
                        ROUND (SUM (rwa) / SUM (p3.ead_post_sec_post_crm), 4)
                DECODE (SUM (p3.ead_post_sec_post_crm),
                        0, 0,
                        ROUND (  SUM (lgd_rate * p3.ead_post_sec_post_crm)
                               / SUM (p3.ead_post_sec_post_crm),
                               2
                TO_CHAR (MAX (a.max_date), 'FMMonth DD, YYYY')
           FROM summary.pillar3 p3,
                (SELECT DISTINCT (month_end_date) max_date,
                                 LAST_DAY (month_end_date) q4,
                                 TO_CHAR (LAST_DAY (month_end_date),
                                          'MON YYYY'
                                         ) q4char,
                                 ADD_MONTHS (LAST_DAY (month_end_date), -3) q3,
                                 TO_CHAR
                                    (ADD_MONTHS (LAST_DAY (month_end_date), -3),
                                     'MON YYYY'
                                    ) q3char,
                                 ADD_MONTHS (LAST_DAY (month_end_date), -6) q2,
                                 TO_CHAR
                                    (ADD_MONTHS (LAST_DAY (month_end_date), -6),
                                     'MON YYYY'
                                    ) q2char,
                                 ADD_MONTHS (LAST_DAY (month_end_date), -9) q1,
                                 TO_CHAR
                                    (ADD_MONTHS (LAST_DAY (month_end_date), -9),
                                     'MON YYYY'
                                    ) q1char,
                                 ADD_MONTHS (LAST_DAY (month_end_date), -12) q0
                            FROM rcdwstg.stg_bcar_detail) a
          WHERE snap_shot_date BETWEEN ADD_MONTHS (a.max_date, -12) AND a.max_date
       GROUP BY CASE
                   WHEN snap_shot_date > a.q3 AND snap_shot_date <= a.q4
                      THEN q4char
                   WHEN snap_shot_date > a.q2 AND snap_shot_date <= a.q3
                      THEN q3char
                   WHEN snap_shot_date > a.q1 AND snap_shot_date <= a.q2
                      THEN q2char
                   WHEN snap_shot_date > a.q0 AND snap_shot_date <= a.q1
                      THEN q1char
                END,
                CASE
                   WHEN snap_shot_date > a.q3 AND snap_shot_date <= a.q4
                      THEN 1
                   WHEN snap_shot_date > a.q2 AND snap_shot_date <= a.q3
                      THEN 2
                   WHEN snap_shot_date > a.q1 AND snap_shot_date <= a.q2
                      THEN 3
                   WHEN snap_shot_date > a.q0 AND snap_shot_date <= a.q1
                      THEN 4
                END,
                pillar3_exposure_class_code,
                pd_band_description
       ORDER BY 2 DESC;I have written the query to get the latest 12 months data from a table and split that into 4 quarter to show in the Cognos Report. But when the table having 13th or the past months data, the select statement is showing Empty values in the first two columns and fetching the 13 month data too.
    Can anyone help me in this to avoid the problem.
    Thanks
    Radha K

    WHERE snap_shot_date BETWEEN ADD_MONTHS(TRUNC(a.max_date, 'MM'), -11) AND  a.max_date
    ....

  • Usgent: using jsp date in sql select statement

    i have something like this:
    String day;
    String month;
    String year;
    select * from event where date = xxx
    where xxx is supposed to be obtained from the strings (day, month, year) and changed into a format that can be compared to in the select statement.
    what should xxx be?
    thks as lot cos i ahe been figuring out for very long.

    Use PreparedStatement and SimpleDateFormat:
    String year = "2002";
    String month = "9";
    String day = "12";
    String sDate = day + "/" + month + "/" + year;
    SimpleDateFormat df = new SimpleDateFormat("M/d/yyyy");
    Date dDate = df.parse(sDate);
    Connection con = DriverManager.getConnection(user, pw);
    PreparedStatement ps = con.prepareStatement("SELECT * FROM event WHERE date = ?");
    ps.setDate(1, dDate);
    ResultSet rs = ps.executeQuery();
    while (rs.next()) {
    rs.close();
    ps.close();
    con.close();

  • Can I pass parameters from a dashboard via a dashboard prompt and presentation variable to publisher report based on a data model with select statements in OBIEE 11g ?

    I have a publisher 11g (v 11.1.1.7)  report with a single parameter. The report is based on a data model not a subject area.  I created a dashboard put a dashboard prompt and link to the report in separate section on the same page.  The dashboard prompt sets a presentation variable named the same as the parameter in the report. 
    The problem was when I created the dashboard prompt, it forced me to select a subject area which I did (though did not want to) and then I created both a column and variable prompts. But clicking on the
    report link completely ignored the value that I thought would be passed in the presentation variable to the report.
    Side note :  My report uses a pdf template for its layout where I have mapped the columns names from my data model to the form fields on the pdf form.  I noticed that if I create a publisher report based on a subject area, then I do not have the choice to choose a PDF as a template type for my layout.  (I only see BI Publisher Template as a choice). 
    I see some documentation online that suggest it could be done in 10g.
    Thanks
    M. Jamal

    Ok,
    I just tried that and it still doesn't pass anything to the prompt.
    I changed the prompt to an edit field and I made the following weblink but when i click the link from an account it doesn't put anything in the prompt and all data for all accounts is shown.
    This is the URL maybe I messed something up...
    https://secure-ausomx###.crmondemand.com/OnDemand/user/Dashboard?OMTHD=ShowDashboard&OMTGT=ReportIFrame&SelDashboardFrm.Dashboard Type=%2fshared%2fCompany_########_Shared_Folder%2f_portal%2f360+Report&Option=rfd&Action=Navigate&P0=1&P1=eq&P2=Account."Account Name"&P3=%%%Name%%%
    thanks

  • Format Date Range in Select Statement e.b. 4/10/14 - 4/09/15

    So far thanks for all the help you've provided me on here. I'm a long time Access developer and have just worked with SQL very little throughout the years but now I'm working full-scale in it, so a learning process for me.
    I am familiar with the DateADD function in SQL DATEADD(mm, 1, GETDATE())  AS MyDate. The part that I'm struggling with is that I need to show a date range in a single field. I can not do it by having that function twice because of the character"-",
    which will throw and error. I played around with the "Convert" function some and I am thinking that a combination of the Convert and DateADD functions would be the way to accomplish this but I'm not sure.
    Basically what I need is using today's date as an example, I would need the result to return 04/10/14-04/09/15. Any assistance would be appreciated.

    This is not being used as a back-end to any type of user interface, so doing it on the front-end is not an option. The data is being exported out to text files, so it needs to be exactly as I had in the example as a single field.
    Thanks all for the feedback. Latheesh's post is the closest to what I need, in fact it's exactly what I'm looking for, which is below.
    Select Convert(varchar(20),DATEADD(mm, 1, GETDATE()),10 ) +' ---- '+ Convert(Varchar(20),DATEADD(mm, 12, GETDATE()),10)
    Ok, I got it working. Actually, turns out that it's not much different than Access syntax other than convert is used in place of Format. DateAdd, DateDiff, etc. are all used in Access as well. Thanks for all the help.

  • Date Processing for Select-Option

    Dear forumers,
    I have a select-option element that takes in a range of PO Date.
    The SELECT statement is as follows:-
    select ebeln
           bedat
           ekorg
           ekgrp
           bukrs
    from ekko
    into corresponding fields of table gt_ekko
    where bedat in s_p_date and   " s_p_date is a select-option for bedat
          ekorg in s_p_org and
          ekgrp in s_p_grp.
    If valid low and high dates are inputted here, then there will be data correctly retrieved into the internal table gt_ekko.
    However, if the low and high dates are equal, then there will be no data retrieved into the internal table gt_ekko at all.
    How can I correct this? Please help. Thanks.
    Additionally, is there an easier way to display this PO date (results) in an ALV list as the dd.mm.yyyy format instead of the yyyymmdd format?

    Janagar,
    I need to have my select-option, s_p_date with an interval (it's part of my requirements).
    types:
    begin of gs_so_input,
      bedat type ekko-bedat,      " PO Document Date
      eindt type eket-eindt,      " Item Delivery Date
      lifnr type lfa1-lifnr,      " Vendor Number
      matnr type ekbe-matnr,      " Material Number
      ekorg type ekko-ekorg,      " Purchasing Organisation
      ekgrp type ekko-ekgrp,      " Purchasing Group
    end of gs_so_input.
    data:
    gs_input type gs_so_input.
    select-options:
    s_p_date for gs_input-bedat obligatory,
    s_d_date for gs_input-eindt,
    s_v_num for gs_input-lifnr,
    s_m_num for gs_input-matnr,
    s_p_org for gs_input-ekorg,
    s_p_grp for gs_input-ekgrp.

  • Executing a stored procedure containing multiple Select statements

    Post Author: Beverly
    CA Forum: General
    I am using Crystal  10.0 against a MS SQL 2000 server.
    I am trying to create a report based on a stored procedure that contains multiple select statements.  The sp requires a single parameter (Claim number) and contains 17 Select statements that produce results.
    I am able to use the Add command and execute the sp with the parameter, but I am only getting the results of the first select statement in the sp back in my data set.  Is there a way to have the data from each Select statement returned to my report?
    I have used Crystal for a while, but pretty much for straight-forward reporting.  I am familiar with the basics of SQL.
    I would appreciate any help anyone can offer.
    Thanks.

    Post Author: BISoftware
    CA Forum: General
    I believe Crystal Reports can only handle one recordset at a time, which means it can only handle a single select statement.  The only way I can see around this would be to break up your stored procedure into multiple stored procedures, so that each only contains a single select statement.  Then, use subreports to report on each individual sp. Hope this helps. - Davewww.BusinessSoftwareResource.com

  • How can i retrieve the output of procedure using a select statement ?

    Hi every one.
    this mite be dumm ?
    how can i use the output of the a procedure containing multiple rows of data in a select statement ?

    This is not  a SQL Developer question. You should ask it in the SQL and PL/SQL forum.
    The short answer is you can't.  Sounds is if you are trying to use MSSQL techniques in oracle. Learn oracle techniques

  • Determine Length of Field in Select Statement

    Hi Experts!
    My officemate has this little problem regarding selection of data based on a certain condition...
    Here is the situation:
    For Example...
    In table KNA1....
    KUNNR       NAME1         Length of Data in Name1
    000001        AA                2           
    000002        AB                2
    000003        ABCD           4
    000004        ABCDE         5
    She only wants to get the records that has the length of 2 in KNA1-NAME1,
    i.e., 'AA' and 'AB' without having to put it in the internal table then make a loop and update the table using the strlen() condition....
    Experts, is this possible? Knowing the length of the data in the select statement? She wants this alternative because it is faster rather than having to loop in internal tables and check if this data has the length of 2 or 3 or 4 and so on....
    Can you please help me out with this one? Thanks in advance!
    <b></b>

    Hi
    If the lenghtn is 6 characters and if you want to fetch only first 2 characters.
    you can use offset
    fetch data from internal table and take variable
    v_var1 = itab-name1+0(2).
    you get only first 2 characters....
    if you want last 2 characters itab-name1+4(2).
    Thanks

  • JDBC: Dynamic select statement

    Hi,
    I am working on a JDBC to SAP integration. I am trying to SELECT data from table for a specific time interval.
    In the JDBC configuration i am using the Query SQL Statement
    For example: select * from X where time='20080808'
    Now is it possible to use for example the system date and time of the server where pi is installed or any other dynamic data?
    Maybe like this: select * from X where time =@sysdate
    If it is possible how? If not why?
    I appreciate your help.
    Thanks in advance...

    Hi,
    In case of receiver JDBC you can map todays date to the select statement and make the select statement dynamic, however in the sender it can't be done. The work around may be to call the stored procedure from the sender adapter and using the stored procedure construct the select query dynamically.
    Thanks
    SaNv...

  • Can i use select statements in LDB

    Hai All,
       Can i use select statements and internal table in a LDB program.
    my requirement is that if i enter company code , fiscal year and reporting periods.
    generally fiscal year will be jan to dec.but in my requirement the fiscal year is apr of previous year to march of currentyear.
    so as i require the last years data can iuse select statement in that ldb program or is there any solution for this.
    Thanks in Advance
    kiran

    Hi Kiran,
    To retrive records from ldb you have to use the
    GET <node> statement. This will invoke the selection screen of the node. An alternate solution is to use the function module LDB_PROCESS.
    Please see the following link for help and example
    http://help.sap.com/saphelp_nw04/helpdata/en/64/237f8cd43711d1950b0000e8353423/content.htm
    Thanks
    Vinod

  • Regarding select statement for this requirement

    Hi................
    good evening
    here is a requirement.
    i want to retrieve data from the following table.but how to join these table is my dought.
    tables  fields
    t001w--werks " plant id
    t001w--name1 " pl;ant name
    t001w--regio " plant address
    ekko--ebeln " purchase  order
    ekko-erdat : creation date
    ekko-ernam "name of the person
    ekpo-ebelp " item
    ekpo-bstyp "purchase order type
    eket-erdat " delivery date
    mara-matnr " material number
    these are the tables and fields.now we want to retrive data from these tables
    how we have to code select statement.
    selection-screen is
    plant id
    order type
    delivery date
    please provide select statement for this requirement.
    thanks and regards.
    k.swaminath  reddy.

    Is this what you are looking for?
    SQL> CREATE OR REPLACE FUNCTION f_team
      2  RETURN VARCHAR2
      3  IS
      4    s_return VARCHAR2(500);
      5  BEGIN
      6    FOR i IN ( select team from t_team order by 1) LOOP
      7      s_return := s_return || i.team || ', ';
      8    END LOOP;
      9   
    10    RETURN substr(s_return, 1, length(s_return) - 2);
    11  END;
    12  /
    Function created.
    SQL>  SELECT f_team FROM dual;
    F_TEAM
    Australia, Bangladesh, England, India, Kenya, Pakistan, South Africa, UAE, USA, West Indies, Zimbabwe
    SQL>

  • Questions on select statement in the data model

    Hi,
    In the select statement, the order by statement seems only to work at the lowest level of the select statement. Is this true?
    What is the the purpose of the group by statement in the select statement?
    As far as I understand, the grouping is catered for in the data model.....
    Regards,
    Kin

    From the oracle report docs:
    The order of column values in a default group is
    determined by the ORDER BY clause of the query for
    SQL queries and by the sort column for Express queries.
    For column values in user-created groups, however, you
    must use Break Order to specify how to order the break
    column's values.So order by in your sql query is affected by groups in your data model.
    The purpose of a group by statement in your select statement is to group values for aggregation purposes, like
    select department_id,
           min(salary),
           max (salary)
      from employees
    group
        by department_id
    order
        by department_id;Grouping in the data model of a report is a little different than a group by clause, but not entirely.

  • Error Extracting data from a STRUCTURE in SELECT statement

    Hi,
    I have an SAP defined structure BIW_KNA1_S which has been enhanced with 2 fields (ZZS1 and ZZS2). I need to populate these 2 fields with data from the 2 SORT fields from ADRC table.
    I tried the following code but i do not get any output. This piece of code is in a FORM statement from which i should return contents of table ITAB in the foll. code.
    DATA ZS TYPE TABLE OF ADRC WITH HEADER LINE.
    DATA ITAB LIKE TABLE OF BIW_KNA1_S WITH HEADER LINE.
    FIELD-SYMBOLS: <FS> LIKE ITAB.
    SELECT SORT1 SORT2 FROM ADRC INTO CORRESPONDING FIELDS OF TABLE
    ZS WHERE ADDRNUMBER IS NOT NULL.
    LOOP AT ITAB ASSIGNING <FS>.
    IF ZS-ADDRNUMBER IS NOT INITIAL.
      <FS>-ZZS1 = ZS-SORT1.
      <FS>-ZZS2 = ZS-SORT2.
    ENDIF.
    ENDLOOP.
    Since i did not get any output, I then added the foll. line of code before the LOOP statement.
    SELECT * FROM BIW_KNA1_S INTO CORRESPONDING FIELDS OF TABLE ITAB
    WHERE KUNNR IS NOT NULL.
    When i execute this, i get the foll. error.
    "BIW_KNA1_S is not defined in the ABAP dictionary as table, projection view or database view."
    How to extract data from a structure BIW_KNA1_S using a SELECT statement.
    Could someone help.
    Thanks

    Hi Roberto,
    Ok. Let me explain my requirement more clearly. I don't want to write the code in include ZXRSAU02. In ZXRSAU02, i will have only PERFORM statement which will call the FORM statement depending on the name of the program.
    Ex: PERFORM form_name ...tables i_t_data.
    In this way, i don't need to make any changes in this file. I will only need to make the changes in the report where my Actual FORM code resides. In the ABAP report, i will have my FORM code which will return contents.
    And this is the code which my FORM report will consist:
    DATA ZS TYPE TABLE OF ADRC WITH HEADER LINE.
    DATA ITAB LIKE BIW_KNA1_S OCCURS 10 WITH HEADER LINE.
    FIELD-SYMBOLS: <FS> LIKE ITAB.
    SELECT SORT1 SORT2 FROM ADRC INTO CORRESPONDING FIELDS OF TABLE ZS WHERE ADDRNUMBER IS NOT NULL.
    LOOP AT ITAB ASSIGNING <FS>.
    IF ZS-ADDRNUMBER IS NOT INITIAL.
      <FS>-ZZS1 = ZS-SORT1.
      <FS>-ZZS2 = ZS-SORT2.
    ENDIF.
    ENDLOOP.
    But as you said, i will have some problems i suppose. Like if my ADRC has some 70 records and if there are 100 records in BIW_KNA1_S, then when i try to copy the fields from ADRC into ITAB (BIW_KNA1_S) i might have problems. I will get back to you once i clarify these things.
    Thanks for your reply.

  • How to fetch negative sign data using select statement

    hi gurus,,
                  i hv  to fetch data which is negative in nature  using select statement i m using ppdit table and wrbtr field.(it contains both negative and positive data)....wat sud i add with select statement...plz help me..
    thnx in advance
    Message was edited by:

    HI,
               I think you can use LT or < 0.0 in the WHERE clause to get all the -ve values. Once you get them treat them as negative.
    Regards,
    Sesh

Maybe you are looking for

  • Unexpected error has occured , when editting a wiki page name

    I am working on SharePoint 2013 , and i have a site collection of type Enterprise wiki. currently when users edit a wiki page and they change the wiki page name, they will get the following error page:- but the modifications will take effect, so if t

  • T510 Wireless connection issue

    I've had a T510 with the Centrino Advanced-N 6200AGN wireless for about 6 months now and it's been great. However, several days ago it started to not connect to my home network's wireless. I've reset the router numerous times and rebooted the laptop

  • Proxy settings for XML iview

    We have been struggling to create an XML iview using the XML iview template since we installed EP 6.0 SP9. We tried to upgrade to SP13, SP14 but still did not work. Recently we upgraded to SP18 and today SP19, and we got a new error message "Runtime

  • SQL Loader error: SQL*Loader-926. Please help

    Hi, While loading some files to my database table, I am getting the following error. I am using 'Truncate' option while loading the file: Error: ==== SQL*Loader-926: OCI error while executing delete/truncate (due to REPLACE/TRUNCATE keyword) for tabl

  • Nspluginwrapper-flash refuses to work

    Hi, some upgrade (don't remember if it was firefox, linux32 or nspluginwrapper) broke nspluginwrapper-flash functionality for me (in firefox). Since then, I have tried numerous things suggested in numerous forums, yet neither nspluginwrapper-flash no