Doubt regarding Date Comparison

Hello,
i am facing a problem in date comparison
SELECT max(l.id)
FROM irf_bill_details l
WHERE to_char(l.agreement_id) = '508814'
AND l.billing_client_id = 'BHPIF'
AND extract(YEAR FROM l.bill_date) < extract(YEAR FROM to_date('01-Jan-2010', 'dd-Mon-yyyy'))
So when i am using this Query m getting the result ...BUT ...
When i use the Below Query .... i am getting NULL ... So the problem surely is in when comparing with months ..?? how to get rid
SELECT max(l.id)
FROM irf_bill_details l
WHERE to_char(l.agreement_id) = '508814'
AND l.billing_client_id = 'BHPIF'
AND extract(YEAR FROM l.bill_date) < extract(YEAR FROM to_date('01-Jan-2010', 'dd-Mon-yyyy'))
AND extract(MONTH FROM l.bill_date)||'-'||extract(YEAR FROM l.bill_date) < extract(MONTH FROM to_date('01-Jan-2010', 'dd-Mon-yyyy'))||'-'||extract(YEAR FROM to_date('01-Jan-2010', 'dd-Mon-yyyy'))
--------------------------------------------------------------------------------------

Aijaz Mallick wrote:
Hello,
i am facing a problem in date comparison
SELECT max(l.id)
FROM irf_bill_details l
WHERE to_char(l.agreement_id) = '508814'
AND l.billing_client_id = 'BHPIF'
AND extract(YEAR FROM l.bill_date) < extract(YEAR FROM to_date('01-Jan-2010', 'dd-Mon-yyyy'))
So when i am using this Query m getting the result ...BUT ...
When i use the Below Query .... i am getting NULL ... So the problem surely is in when comparing with months ..?? how to get ridAre you saying that you're still getting one row of output, but the id on the row is NULL?
SELECT max(l.id)
FROM irf_bill_details l
WHERE to_char(l.agreement_id) = '508814'
AND l.billing_client_id = 'BHPIF'
AND extract(YEAR FROM l.bill_date) < extract(YEAR FROM to_date('01-Jan-2010', 'dd-Mon-yyyy'))
AND extract(MONTH FROM l.bill_date)||'-'||extract(YEAR FROM l.bill_date) < extract(MONTH FROM to_date('01-Jan-2010', 'dd-Mon-yyyy'))||'-'||extract(YEAR FROM to_date('01-Jan-2010', 'dd-Mon-yyyy'))
--------------------------------------------------------------------------------------Whenever you have a problem, post some sampel data (CREATE TABLE and INSERT statements) and the results you want from that data. Explain how you get those results from that data.
As long as I don't know where you're starting from (sample data) or where you want to go (results) it's hard for me to give you good diorections.
I suspect you want to be using TRUNC rather than EXTRACT, if not a plain DATE comparison.
For example, if you have a string p_cutoff_date (such as '01-Jan-2010', but not necessaily the 1st of the month) and you want to see if l.bill_date is earlier than the beginning of the month that contains p_cutoff_date, then:
WHERE   l.bill_date < TRUNC ( TO_DATE ( p_cutoff_date
                                      , 'dd-Mon-yyyy'
                   , 'MONTH'
                   )As you said in the subject line, you're trying to compare DATEs. So compare DATEs: don't convert them to NUMBERS (using EXTRACT) and then to strings (using ||); keep the DATEs as DATEs.

Similar Messages

  • Doubt regarding Data transfer from R3 to BW

    Hello Experts,
    I have a basic questions to ask,I am curious to know that how the data is transfered from a
    remote system (let say R3 or CRM) to BW system.Though i know that two systems
    make a RFC connections and make use of idocs.
    But if somebody can through more light on this and help me clear my doubts.
    Also case when the data is transfered with in BW.
    Thanx and Regards
    Priyanka

    Hi,
    Chek in teh follwoing PDF you will get some Idea.
    http://sap-idoc2edi-consulting.com/pdfFiles/EDI_IDoc_Overview.pdf
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/908836c3-7f97-2b10-4cb8-e6790361c152
    Thanks
    Reddy

  • Doubt Regarding Dates

    Hello,
    I want a list of dates of last 15 days from the date i pass ... how to achieve this ia a sql query...
    & i also want to display 'January - December' in a query ..
    plz help.

    Try this,
    SQL> SELECT &p_date - LEVEL dt
      2    FROM DUAL
      3  CONNECT BY LEVEL <= 15;
    Enter value for p_date: sysdate
    old   1: SELECT &p_date - LEVEL dt
    new   1: SELECT sysdate - LEVEL dt
    DT
    25-APR-11
    24-APR-11
    23-APR-11
    22-APR-11
    21-APR-11
    20-APR-11
    19-APR-11
    18-APR-11
    17-APR-11
    16-APR-11
    15-APR-11
    14-APR-11
    13-APR-11
    12-APR-11
    11-APR-11
    15 rows selected.
    SQL> SELECT TO_CHAR ( ADD_MONTHS ( TRUNC ( SYSDATE, 'YYYY'), LEVEL - 1), 'MONTH') mnth
      2    FROM DUAL
      3  CONNECT BY LEVEL <= 12;
    MNTH
    JANUARY
    FEBRUARY
    MARCH
    APRIL
    MAY
    JUNE
    JULY
    AUGUST
    SEPTEMBER
    OCTOBER
    NOVEMBER
    DECEMBER
    12 rows selected.
    SQL> G.

  • Doubt regarding data declaration in update routine!

    Hi,
    i had added one field in cube, update rotuine for which is in due.
    in the update routine logic i have to assign this field to another field if some condition satisfies!
    the logic is --
    if Hstatus=c
    close_date=stdatum.
    close_date is the field i had created and added in info cube definition.
    now, how to declare these fileds in routine as it is asking me to declare the fields
    can any body suggest me how to declare those fields!
    Thanks,
    Ravi

    Hi,
    In cube, for updating every keyfigure, all the characteristics will be taken into account. So, in cube if you choose a keyfigure in characteristic tab you can find all the characteristics. Likewise you can find for all the keyfigures.
    So, Transfer routine for all kefigures will transfer the same routine of the characteristic for all the keyfigure. (that means if you choose different keyfigure and if you choose a the same characteristic you can find the same routine, no need to create separate ) If you choose no, it wont transer the same routine to all the keyfigures for the characteristic. You can define the separate routine for the characteristic for every keyfigure.
    in ODS this is not the case. There only Keyfields only will be common for all the datafields.
    rgrds,
    v.sen.
    Message was edited by:
            Senthilkumar Viswanathan

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

  • Doubt in data element creation

    Hi,
        I have doubt in data element creation ie, there is 2 options elementary type
    (domain and built-in-type) and reference type (name of the reference type &
    ref to predefined type). if there is built in type here then what is the use of
    built-in-type in initial screen of the table and also explain me about the use of
    reference type.
    with regards,
    nanjunda sharma

    Hi!
    With the use of the built-in type, you have to set always in every different data element the exact type.
    With the use of the domains (pre-defined types) you just have to enter the domain name into the data element. If you have to modify the type, you can maintain it in the domain (only once) but the built in types have to modifyed in every data element (which means more work).
    Domains have a little more options also, than the built in types.
    Regards
    Tamá

  • Doubt regarding  ALE SETTINGS in IDOC scenario.

    Hi Friends,
            I have some doubts regarding ALE settings for IDOC scenarios,  can anyone  please clarify my doubts.
    For exmaple take IDOC to FILE scenario
    The knowledge i got from SDN is --
    One need to do at the  R3 side is  --- RFC DESTINATION (SM59)  for the XI system.
                                                       --- TRFC PORT  for sending IDOC  to the  XI system
                                                       --- CREATING LOGICAL SYSTEM
                                                       --- CREATING PARTNER PROFILE 
                   at the XI side is  --- RFC  Destination ( For SAP sender system)
                                           --- CREATING  PORT  for receiving IDOC from the SAP sending system(IDX1).
    1. Do we create two logical systems for both Sender ( R3 system ) and Receiver( XI system ) in R3 system itself or in XI system or in both systems we create these logical systems? Is this a mandatory step in doing ALE configurations?
    In IDOC to IDOC scenario-------
      2.  Do we craete two RFC destinations in XI system? One RFC DESTINATION for the Sender R3 system and another RFC DESTINATION for the Receiver R3 System? and do we create RFC DESTINATION for the XI system in receiver R3 system? If not.....y we don't create like this........Please give me some clarity on this.............
      3.  If we use IDOC adapter ,since IDOC adapter resides on the ABAP STACK ,we don't need sender communication channel ,for the similar reason----
    y we r creating receiver communication channel in the case of FILE to IDOC scenario?
      4. Can any one please provide me the ALE settings for IDOC to FILE scenario,
                                                                                    FILE to IDOC scenario,                                                                               
    IDOC to IDOC scenario individually.
    Thanks in advance.
    Regards,
    Ramana.

    hi,
    1. Yes, we create two logical systems for both Sender ( R3 system ) and Receiver( XI system ) in R3 system itself and
    it is a mandatory step in doing ALE configurations
    2. We create 1 RFC destination each in R3 and XI.
        R3 RFC destination points to Xi and
        XI RFC destination  points to R3
    3 We need to create Communication Channel for Idoc receiver as the receiver channel is always required but sender may not be necessary
    4. ALE settings for all IDOC scenarios are same  as follows....
    Steps for ALE settings:-
    Steps for XI
    Step 1)
         Goto SM59.
         Create new RFC destination of type 3(Abap connection).
         Give a suitable name and description.
         Give the Ip address of the R3 system.
         Give the system number.
         Give the gateway host name and gateway service (3300 + system number).
         Go to the logon security tab.
         Give the lang, client, username and password.
         Test connection and remote logon.
    Step 2)
         Goto IDX1.
         Create a new port.
         Give the port name.
         Give the client number for the R3 system.
         Select the created Rfc Destination.
    Step 3)
         Goto IDX2
         Create a new Meta data.
         Give the Idoc type.
         Select the created port.
    Steps for R3.
    Step 1)
         Goto SM59.
         Create new RFC destination of type 3(Abap connection).
         Give a suitable name and description.
         Give the Ip address of the XI system.
         Give the system number.
         Give the gateway host name and gateway service (3300 + system number).
         Go to the logon security tab.
         Give the lang, client, username and password.
         Test connection and remote logon.
    Step 2)
         Goto WE21.
         Create a port under transactional RFC.(R3->XI)
         Designate the RFC destination created in prev step.
    Step 3)
         Goto SALE.
         Basic settings->Logical Systems->Define logical system.
         Create two logical systems(one for XI and the other for R3)
         Basic settings->Logical Systems->Assign logical system.
         Assign the R3 logical system to respective client.
    Step 4)
         Goto WE20.
         Partner type LS.
         Create two partner profile(one for XI the other for R3).
         Give the outbound or inbound message type based on the direction.
    Step 5)
         Goto WE19
         Give the basic type and execute.
         fill in the required fields.
         Goto IDOC->edit control records.
         Give the following values.(Receiver port,partner no.,part type and sender Partner no. and type)
         Click outbound processing.
    Step 6)
         Go to SM58
         if there are any messages then there is some error in execution.
         Goto WE02.
         Check the status of the IDOC.
         Goto WE47.
         TO decode the status code.
    Step 7)
         Not mandatory.
         Goto BD64.
         Click on Create model view.
         Add message type.
    BD87 to check the status of IDOC.
    In case if not authorized then go to the target system and check in SU53, see for the missing object
    and assign it to the user.
    SAP r3
    sm59(status check)(no message)
    WE02(status check)
    WE05(status check)
    BD87(status check)
    Xi
    IDx5(Idoc check)
    SU53(authorization check)
    Reward points if helpful
    Prashant

  • Idoc data  comparison between different R/3 clients.

    Hi ppl ,
    Is there a way idoc comparison can be done between different clients without going
    by Segment by Segment comparison ?
    I have a requirement wherein i have thousands of idocs in QA system and i need to
    compare those with the ones in PROD system. The segments in the idocs may vary
    depending on the data that flows from the third party system which will post idocs in R/3.
    So, the segment wise comparison of data is also ruled out .
    Do we have any standard reports which will help in achieving this purpose ?
    Please let me know how the idoc data comparison can be carried out .
    Regards,
    Nick.

    Hi Nick,
    There is no standared tools available for comparing the data of two idocs.
    By using beyond compare s/w you can check the data, but the thing is you have to download the idoc data to file format.
    By using Idoc_xml_transform function module you can download idoc data to xml format, after you can compare.
    Check this
    http://download.cnet.com/Beyond-Compare/3000-2242_4-10015731.html
    Regards
    Ramesh

  • Doubts regarding XML Form Builder

    Hi All,
          I am having some doubts regarding XML Forms (Projects) that is created using XML Form Builder. Where are exactly these projects stored. Can I edit these projects and add my own Java Functionality in these. And also the data which I fill using these project where is it stored. Suppose New Project I ve created using XML Form Builder, now I want to feed in the news. Where exactly are these news stored.
    Thanks in Advance
    Anish

    Hi Anish
    You can make the standard settings and modify the XML forms builder in line with your requirements in the options. You can set the standard paths for your project on the <b>Paths</b> tab page.
    To get a clear understanding, please go through this link.
    http://help.sap.com/saphelp_erp2004/helpdata/en/62/ca6f365a6df84e87ba085f9b5fb350/content.htm
    Hope that was helpful
    Warm Regards
    Priya

  • Doubt Regarding Statistics Collection in 10g

    Hello,
    Me Jr Dba i have a doubt regarding statistics calculation in 10g.As we know that if we set
    the initilization parameter STATISTICS_LEVEL=Typical then AOS(Automatic Optimizer staistics) calculate the statistics for the tables, whose blocks are greater then 10% changed from the last calculation.Here my doubt is since already statistics are gathered,
    is there any necessity for us to gather the statistics manually by using
    DBMS_STATS.GATHER to see the tables or system statistics.
    Can u plz assist me on the above
    Regards,
    Vamsi

    Hi,
    Please see here,
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/stats.htm#i41448
    If the table/s are changing very frequently than its better to gather the stats manually.This would lead teh volatile table coming up into the stats job again and again.
    For the system stats and data dictionary stats,they are not collected by default.So there is no choice but to gather them manually.
    Aman....

  • Doubt regarding SQL execution

    Hi Friends,
    Am using Oracle 10g DB - 10.2.0.3.0
    I have some basic doubts regarding sql query execution by Oracle.
    Say, Am executing a query from a toad/sqlplus session for the first time, it takes 10 secs then 1 sec and so on.
    Same thing happens for every 15 minutes.(Any specific reason for this ??).
    It takes more time when it executes first because of parsing and all those stuff but from then on it picks from the
    shared pool right??.. How long will it be there in Shared Pool does Oracle maintain any specific time period to clear that query from shared pool memory. How does Oracle handle this.
    Another thing is, say, I have a report query, I run this query monthly. What will be the execution time when I run this query each and every month. Will Oracle parse this query everytime I run. How do I improve the performance in this situation (May sound odd :)).
    Regards,
    Marlon

    Say, Am executing a query from a toad/sqlplus session for the first time, it takes 10 secs then 1 sec and so on.
    Same thing happens for every 15 minutes.(Any specific reason for this ??).
    It takes more time when it executes first because of parsing and all those stuff but from then on it picks from the
    shared pool right??.. How long will it be there in Shared Pool does Oracle maintain any specific time period to clear that query from shared pool memory. How does Oracle handle this. Share Pool caches the SQL statement. So when you execute the same SQL for the second time it goes for a soft parse. But this is not the only reason for the query to execute faster the second time. The time difference between a soft parse and hard parse is very minimal. So it really does not matter unless you are executing the same query several number of times.
    The thing that really matters is the Data Buffer Cache. That is the rows that are selected by your query are cached into the Data buffer that is available in the SGA. So for the next time when you run the same query the IO is reduced as the data is available in the memory and you don't have to go to your disk to get the data.
    But the data in Data Buffer is not persistent, meaning it follows the FIFO rule. That is first in first out. When the Data Buffer is full the content of the buffer is removed in the FIFO order.
    Another thing is, say, I have a report query, I run this query monthly. What will be the execution time when I run this query each and every month. Will Oracle parse this query every time I run. How do I improve the performance in this situation (May sound odd :)). Like the Data Buffer the Shared Pool is also maintained in the FIFO order. So if the query is still in the Shared Pool the query will be soft parsed else it will be hard parsed. But its very rare that you will have a query in your Shared Pool for a month.

  • Question on How to Use LI and NP Data Comparison Report

    Hi,
    We are trying to figure out how to make the Transaction Code PC00_M42_LLPD (LI and NP Data Comparison Report) work. What file type (.xls, .txt, etc) should be used?  Anyone who is familiar with the transaction, please help.
    Best Regards,
    Bry

    Somewhere in the Oracle 8.0 documentation it is stated that one
    enviroment per each thread is required if I want to ensure
    complete concurrency of different threads accessing databases.
    But isn't this a waste of resources since only Handle Alloc &
    Free functions use Enviroment handle, hence they should be
    mutexed for access from concurrent threads.
    But the most time-consuming functions are ServerAttach &
    SessionBegin which shouldn't be mutexed since they have each
    their own Server/Session handle.
    So my question is if a single OCI Enviroment is enough for the
    most demanding tasks or should I create one enviroment per
    thread?
    Most folks are happy with a single environment. The mutex on the
    env handle is only taken when the OCI library is allocating some
    memory for internal operations.
    Tomislav.

  • Doubts regarding WAN Network sizing formula parameters

    Hi
    We have used the following SAP document - Front end requirements for SAP Business solutions
    We have some doubts regarding the formula. Sometime we have the feeling it does not address very well issues as user's concurrency, WAN Optimization and contingency. However,  it might be only that we are not using correctly the formula, so we would like to confirm some information regarding the parameters.
    C = X * N * D * 0.25
    The parameters are as follows:
    C: Bandwidth in kbps that is needed for the SAP GUI
    X: Amount of data per dialog step in kilo bytes
    N: Number of active users (independent of the number of sessions)
    D: Average number of dialog steps per minute per user7
    Numerical factor: ~0.25 = 8 (kb/kilo bytes ) * 1.25 (protocol overhead) * 1/60 (min/s) * safety factor
    1.58 (response time, peak load, different technologies)
    The number of active user is the average number of concurrent users (from the total number of users) which are using the network? Therefore, we should calculate first the concurrent users number?
    Does any body knows what is the reasoning behind the Numerical Factor and the safety factor? It is a contingency factor? It is related with a network bandwidth contingency?
    Has anyone apply WAN Optimization?
    Has anyone apply any additional contingency measure additional to the safety factor?
    Kind regards
    Gonzalo Pérez-Prim

    Hi Gonzalo,
    As you said, the number of active users is the mean number of concurrent users, since idle users don't normally need bandwidth.
    I think that safety factor is an estimated number provided by SAP engineers to increase the final amount, just in case you have different issues that could lead to a lower network transmission rate. As it's a general estimation, please take into account that the particular issues of your network can have some influence in the speed calculation.
    Please take into account that maybe you want to switch the option "slow network connection" in SAPGUI, just to decrease the ammount of traffic between frontends and server.
    Hope this helps
    Best Regards
    Francisco

  • Doubts regarding the CTTYP field after a PU12 run

    Hi Everyone,
    I had some doubts regarding PU12. When I maintain the IT16 data for an employee belonging to Employee Group/Subgroup E/52, I want to keep the contract type blank. However, when I do this, CTTYP is not sent through in the IDoc after PU12 processing. I would like to know if this is standard behaviour. (If it is maintained as say unlimited contract, the field is sent through with the value 01) If I would like to send CTTYP through as 00, can I do it? Would I have to maintain a conversion? As of now, this field is configured as a key field in my system.
    Regards,
    Alpana.

    I presume that you cave a template for your documents with unsigned signature fields. Add a text filed (or other field type that you wish to use) to this template. Then you will be able to fill in this field after signing.

  • Doubts regarding RRI

    Hello Friends,
    I have some doubts regarding RRI, please go through below questions.
    I have 2 queries 1. sales report  2. Sales report world
    I have built a jump target in RSBBS by giving sender and receiver details
    In sales report I have the following data, my useer requirement is If he select one material -> right click -> goto -> jump to world report, then he wants to see the data for only that particular material , bu in my case it is showing for all the materials which are in 1st query.
    Material--Dist Channel-Month
    098647A639          G2     201002
    098647A781          G2     200909
    0265231927          G2     200901
    0986479560          G2     200912
    0204011474          G2     200912
    098647A711          G2     201002
    098647B772          G2     200909
    0986473371          G2     200901
    0265216627          G2     200901
    1987482222          G2     200901
    1987482202          G2     200901

    Hi,
    I have same requirement, I achieved by selecting go to on the respective company, Sales document (in my case). I have done no settings in assignment details.
    I have another RRI requirement.
    When we are in the report for Invoice, when we click on the Billing Document, It should go to transaction "VF03" in R/3.
    I can able to achieve (we have SSO logon configured).
    My requirement is when we select goto VF03, it should go to the respective billing document on which we right clicked, now i'ts displaying only VF03 transaction. It should display display of the respective Billing Document.
    Can anyone help to resolve the issue?
    Thanks in advance,
    Venky

Maybe you are looking for

  • Ibook screen cracking

    My ibook screen is starting to crack on the left had side, not the LCD it;s self but the plastic part. I have taken excellent care of it never droped it and its ALWAYS in it's case when not in use. It's still under warranty should I bring it to an Ap

  • Need Third Party software recommendation - duplicates management and remova

    I have read several dozen discussions addressing duplicate file/song removal from itunes, and many recommend third party software. While there is a 'show exact duplicates' command in itunes at Shift:File->Show exact duplicates, in my case all it did

  • System Landscape Design for EP-ESS Production Environment

    Hi Experts, We are about to implement SAP Employee Self Service solution through SAP Enterprise Portal 6.0 on our Production server.Our activity on development server is completed.The Backend version we are using is R/3 4.7C and using ITS for integra

  • How to run html 5 on Safari

    Arsenal website asks for html 5 to run their videos. Is there an easy way to run it on Yosemite with Safari. Please can anyone help?

  • Quick question to do with install cd.

    Hi, I was just wondering what exactly the install cd does. See, my pc wouldn't recognize my mini, so I put in the install cd (second time using it, my mini was working fine before this day) that came with the mini and followed the steps. Now it works