Want to write formatted search based on date

Hi,
I want to write formatted search where one date is lesser than other date.But it is giving error stating like date comparision not possible
Pls advise

Hi Sanjay,
SQL DateDifferent Function.
for example.
DECLARE @StartDate DATETIME
DECLARE @EndDate DATETIME
SET @StartDate = $[ODLN.DocDate]
SET @EndDate = $[ODLN.TaxDate]
SELECT DATEDIFF(Year, @StartDate, @EndDate) AS NewDate
Check the thread, You will be get more details of SQL Date Different Function.
http://sqltutorials.blogspot.com/2007/06/sql-datediff-function.html
Regards,
Madhan.

Similar Messages

  • Formatted search based on screen entry

    Hi,
    I need help to create a formatted search based on a field that the user entered on the screen. For example, I want a formatted search on the Purchase Order screen where the item search will only show the items where the vendor entered in the Default Vendor field of the master record is the same as the vendor specified in the Vendor field of the purchase order.  Please advise on the correct sql statement.
    Thanks,
    Jane

    Thanks Sudah! That worked!
    However, I do not understand the syntax.  What does [dbo] mean?
    I am trying to duplicate the query for the following scenario.
    I have a user defined field U_Freight in the Business Partner Master Data (OCRD) and also in the sales order screen. I want to create a formatted search for the freight field in the sales order to automatically find the freight from the business partner master data screen based on the customer entered in the sales order.
    I have tried the following as a formatted search on the sales order screen, but it does NOT work.
    SELECT T0.U_FREIGHT FROM [dbo].[OCRD] T0
    WHERE T0.CardCode = $[$4.0.0]
    Please advise.
    Thanks!

  • Formatted Search for Delivery Date field in SO not working

    Hi All
    Can anyone help me as to why my formatted search is not working?
    I am currently using SAP B1A SP01 Patch 19.
    I have created a user query as follows:
    SELECT $ [$10.0.DATE] + 5
    When I add this to the delivery field within the Sales Order and bring through the saved query which I set to auto refresh when the Posting Date field changes and to Display Saved Values it doesn't work.
    Any ideas?
    Thanks and best wishes
    Gail

    HI Gail,
    If I am not mistaken you want to add days to the posting date...if that is so then try this out:
    SELECT $[ORDR.DocDate.DATE]+5 From ORDR T0 For Browse
    Set The indicator to Auto Refresh when the fields change
    Nagesh

  • Search based on data

    Hi
    Does BerkeleyDB support a search based on the data stored along with a key.
    I know that it supports a search based on both key and data.
    Thanks
    Obomo

    Hi Obomo,
    The functionality you are requesting is provided by secondaries.
    Documentation is here: http://www.oracle.com/technology/documentation/berkeley-db/db/ref/am/second.html
    Regards,
    Alex

  • Formatting Output Based on Data in TVARVC

    Hi Guys
    In the below program I need to highlight lines of output where the plant complies to the rules green and those that do not in red in a variant called check plant.
    Here are the values.
    S    0000 I    EQ   1000
    S    0001 I    EQ   3000
    S    0002 I    BT   2000                                          2500
    S    0003 I    BT   6100                                          6150
    S    0004 E    EQ   2300
    S    0005 E    EQ   6101
    I have tried to achieve this in the code below but it doesn't work properly some plants are highlighted green when they should be red and vice versa. Please could you help me with the correct logic.
    REPORT  ZTREVOR_CHECK_VARIANT message-id ZTREVOR_MSG_CLASS1.
    data: it_makt type standard table of makt,
          wa_makt type makt,
          it_mard type standard table of mard,
          wa_mard type mard,
          it_t001w type standard table of t001w,
          wa_t001w type t001w.
    Data: it_mard_distinct type standard table of mard,
    v_werks type werks,
    v_matnr type matnr.
    data: it_tvarvc type standard table of tvarvc,
          wa_tvarvc type tvarvc.
    CONSTANTS : C_VARNAME TYPE rvari_vnam value 'CHECK_PLANT'.
    select-options : s_matnr for v_matnr no intervals no-extension,
    s_spras for wa_makt-spras no intervals no-extension.
    AT SELECTION-SCREEN.
      SELECT single matnr from mara into v_matnr WHERE matnr in s_matnr.
      IF sy-subrc IS NOT INITIAL.
        MESSAGE w000 with s_matnr-low display like 'I'.
        ENDIF.
    start-of-selection.
    select * from makt into table it_makt where matnr in s_matnr and spras in s_spras.
    select * from mard into table it_mard where matnr in s_matnr.
    select * from tvarvc into table it_tvarvc where name = C_VARNAME.
    end-of-selection.
    IF it_mard is not initial.
    sort it_mard by werks.
    LOOP AT it_mard INTO wa_mard.
        IF wa_mard-werks NE v_werks.
          APPEND wa_mard TO it_mard_distinct.
        ENDIF.
        v_werks = wa_mard-werks.
      ENDLOOP.
    select * from t001w into table it_t001w for all entries in it_mard_distinct where werks = it_mard_distinct-werks.
    endif.
    write : at / 'Material' color col_positive,
      10 'Description' color col_positive,
      30 'Plant' color col_positive,
    60 'Plant Name' color col_positive.
    LOOP AT it_mard_distinct into wa_mard.
      READ table it_makt into wa_makt with key matnr = wa_mard-matnr binary search.
      READ table it_t001w into wa_t001w with key werks = wa_mard-werks.
    READ TABLE it_tvarvc into wa_tvarvc with key low = wa_mard-werks.
    if wa_tvarvc is not initial.
    FORMAT color = 5.
        else.
          FORMAT color = 6.
        endif.
      write : at / wa_makt-matnr,
      10 wa_makt-maktx,
      30 wa_mard-werks,
      60 wa_t001w-name1.
      endloop.

    you are crosschecking with TVARVC the wrong way.
    At least you cant check for equality.
    See in tvarvc there are not only single variables (parameters), but also ranges (select-options).
    I assume the small list in the top of your post is an excerpt of your TVARVC entries for plant checks.
    As you can see there are select option using option BT (between)
    when you select on tvarvc with LOW field you will never get those which are between the customized entries.
    what you need to do is select your TVARVC entries, make a range out of it and check your plant like following:
    loop at it_mard_distinct into wa_mard.
      If wa_mard-werks IN range_plants.
        colour green.
      else.
        colour red.
      endif.
    endloop.
    hope you could follow me.

  • I want to create a report based on date ranges...

    I have surfed the forum and seen all of the responses and can't get anything to work.
    This is where I am:
    select     OBJECT_ID,
         EVENT_CATEGORY,
         EVENTS_TITLE,
         EVENTS_DATE,
    OBJECT_ID "Click Icon For More Info"
         from EVENTS
    where     EVENT_CATEGORY = :P3_EVENT_CATEGORY and EVENTS_DATE between to_date(:P3_START_DATE,'DD-MON-RR HH:MI') and to_date(:P3_END_DATE,'DD-MON-RR HH:MI');
    When I input actual data for my querry:
    select     OBJECT_ID,
         EVENT_CATEGORY,
         EVENTS_TITLE,
         EVENTS_DATE,
    OBJECT_ID "Click Icon For More Info"
         from EVENTS
    where EVENT_CATEGORY = 'Category 1' and EVENTS_DATE between '04-MAY-06 10:57 AM' and '12-MAY-06 02:27 PM'
    It works!
    Please help

    Either
    1. Make sure the page is submitted so that those 2 items (P3_START_DATE and P3_END_DATE) get saved into session state and can be used by the report
    or
    2. Make sure both the items have the apppropriate Source or Default values defined so that the initial run of the page will display the report properly
    or
    3. Put a condition on the report region to not display until 1 (or both) of those 2 items have a non-null value.
    Hope this helps.

  • BP SEARCH BASED UPON DATA IN CONTACT PERSON RELATIOSHIP:WEBCLIENT

    HI GURUS,
    CAN U PLEASE THROW SOME LIGHT ON THE ISSUE. ITS VERY URGENT...UR HELP WILL BE HIGHLY APPRECIATED AND REWARD POINTS PROMISED...THANKS IN ADVANCE.
    > In business partner identification we are using the
    > contact record first and the company record second.
    > We are going to use the information on the address
    > fields to identify phone, fax and email.The current
    > address set up is to use the Relationship
    > information to house the address information for the
    > contact record.
    > an the telephony (CTI) integration read the
    > relationship information, without customization? Or
    > another way of phrasing this is can the standard
    > mappings from within CTI read the relationship data
    > on the customer to contact BP?
    >
    >
    > Thanks and we await your response
    JAI MISHRA

    Jai,
    You could anytime do an enhancement to read the relationships for a BP whenever an incoming call is there. I think you could also make it specific to only incoming call as well.
    I am not sure if there is some customizing to navigate directly to relationship form the BP data.
    Cheers,
    Ankur

  • Formatted Search Querry for UDF

    Dear All,
            My client is using SAP B1 2007 B PL10. Now I am facing a issue like, I have made a UDF in the A/P Invoice Form and hence made it mandatory. But when i make a UDF field as mandatory I have to write a particular default value.  Hence i have written default Value as 0.
          Now whenever i open the A/P Invoice Form,  the mandatory UDF Field is showing default value as 0. But I want to write a Formatted Search Based Querry in a way that the UDF Field should become Nil whenever I Open the A/P Invoice Form.
          Please guide me in writing the Formatted Search Querry by which the UDF Field which is having a Default Value as '0' should become Nil.
        Regards
    Hitesh Parsawala

    Hi Hitesh ,
    You have two option :
    1.Either donot make ur UDF mandatory at the time of creation
    Use sp_transaction notification to validate
    2. Define UDF manadatory at the neginning
    if user donot change the value , triggger approval procedure through FMS
      I think it is
    Select Distinct 'True' from tablename where <userdefined field =''i
    If user donot change, it is going to triger approval procedure
    <You can look for code in forum if that is not working >
    Hope this helps
    Bishal

  • Formatted search with UDF and syntax question

    Can you explain the syntax with when to use the dollar sign and negative in writing a query for a formatted search based on user entry?
    I now want to create a formatted search to pull values based on the user's entry into a UDF on the item master screen.
    User entry into UDF U_Customer Code
    to create Formatted search for UDF U_Rep01
    I tried the following, but it does not work.
    SELECT T0.U_REP01 FROM dbo.OCRD T0
    WHERE T0.CARDCODE = $http://$OITM.U_CUSTOMERCODE
    Thanks.
    Please advise.

    The right syntax would be like this:
    SELECT T0.U_REP01 FROM dbo.OCRD T0
    WHERE T0.CARDCODE = $[OITM.U_CUSTOMERCODE\]
    However, the logic of query may not be correct.  Select something must be already in the system and Where should also be locatable.
    Thanks,
    Gordon

  • Formatted Search - Calculate GP Base Price for Non Inventory Items

    Hi Experts,
    On one of our customer's 8.8 PL 15 installation, requirement was to calculate GP for Non Inventory Items (on SO screen). Since SAP does not automatically calculates it we proposed and implemented following solution.
    1. Have all Non Inventory Items to be costed at Standard cost so that you can manually enter the cost in the Item Master.
    2. Write following formatted search on GP Base Price field so as to calculate the GP Base Price for the Non Inventory Items only. The formatted search must not make any changes to Inventory Items as we want system to calculate the GP automatically (just in case cost changes from SO to Delivery or Invoice).
    DECLARE @II AS nVarchar(1)
    DECLARE @COST AS Numeric(19,2)
    SET @II = (SELECT OITM.InvntItem FROM OITM WHERE OITM.ItemCode = $[RDR1.ItemCode])
    SET @COST = (SELECT     (OITW.AVGPrice * $[RDR1.NumPerMsr]) FROM     OITW WHERE     OITW.ItemCode = $[RDR1.ItemCode] AND
         OITW.WhsCode = $[RDR1.WhsCode])
    IF (@II = 'N')
    BEGIN
    SELECT @COST
    END
    3. Formatted search achieves what was originally required however if a user overwrites the Item Code (Inventory Item) in the SO then above formatted search clears the GP Base Price field and sets the GP basis for the item as "Manual". By obverwrite means user first selected item A0001 on line 1 and then entered A0002 on same line i.e. Line 1.
    My question here is what is wrong in the formatted search that is resulting in this behaviour.
    Any questions please let me know.
    Thanks in advance.
    Regards
    Devinder

    Hi Gordon,
    Thanks for taking out time to help me however Key requirement here is
    Write formatted search on GP Base Price field so as to calculate the GP Base Price for the Non Inventory Items only.
    Your query sets the base price for GP Base Price for Inventory Item to ZERO and Base Price By to Manual.
    Note that my Formatted search has a problem only when an Inventory Item line is overwritten. I am not sure if this is a problem with SAP itself rather than my query.
    Any other ideas please?
    Regards
    Devinder

  • Formatted Search on Serial Number (goods receipt PO)

    Dear Expert,
    I have the problem on generate Serial Number. I want to used formatted search to created serial number,
    the structure of serial number is :  x-99-9999-9999-99999
    1st   x = type of product (Regular, Consignment, Tenant)
    2nd  999 = Brand type
    3rd   9999 = Category
    4th   9999 = Year received
    5th   99999 = counter number
    for example : Item A with quantity 100 units,
    so.. what the formatted search that I want 
    On window serial number (detail level), I pressed Shift F2, so.. "the formatted search " will fill in each row on detail level until quantity (header level) --> will fill in until row 100
    I do not want used Generate Serial number which SBO facility, because it is many step to used it so that our user (warehouse staff) will confuse to used it.
    Does anyone have solution to solve my problem?
    Thanks before.
    regards,
    Hendra

    Dear Hendra Sulivan 
    Formatted search is basically used for getting data from your data base. It will not allow you to enter any data in your data  base.
    So your query can be solved only by using SDK.
    I can suggest you that through SDK you can provide standard Serial no entering screen where he will just enter the kind of serial no.
    This facility can be provided by using tab on Serial no screen.
    thanks,
    yatindra gokhale

  • Replace system formatted search

    Hi experts,
    I need to delete a formatted search which is predefined in SAP.  Is this possible?  I want to replace the formatted search to get data from another table.
    The field I am talking about is the 'Project' field in the Cost Accounting tab of the Fixed Asset Master Data.
    Any ideas please?
    Thanks,
    vankri

    Hi Vankri,
    Yes, you can remove the predefine FMS. But you have to do it manually. To remove FMS on attached field press ShiftAltF2 and then select first option Without Search in User-Defined Values then press OK.
    Regards,
    Datta Kharat

  • Select Query Based on date condition

    Hi ,
    Is it Possible.
    i want to run select query based on date condition.
    Eg...
    if the date between 01-jan-01 and 01-jan-05 then
    select * from table1;
    if the date between 02-jan-05 and 01-jan-08 then
    select * from table2;
    Becaz i have data in 2 diffrent tables , based on the date condition i wnt to run the select statement to diffrent tables.
    i dont want plsql here Just SQL needed.
    thanks,
    -R
    Edited by: infant_raj on May 5, 2009 11:48 PM

    Helo Kanish,
    this is not the one i was asking..
    wht i mean was .
    i use bind variable to get date while running the select statement , once i get the date then i want to choose any one of the table to run select query.
    EG..
    select col1,col2 from table1 where date between only if 01-jan-01 and 01-jan-05;
    select col1,col2 from table2 where date between only if 02-jan-05 and 01-jan-08;
    Run any one of the two . not all
    thanks,
    _raj                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to provide formulae for the columns in report based on date column

    Hi,
    How can we provide formulae for the columns in report, where each column is based on another Date Column.
    Can anyone suggest on this.
    Thanks

    Hi Manu,
    I think you a logical column X on which you created another Logical Column Y.
    Now you want 'Y' to be filtered based on Date Column.
    1. If, my assumption is right - You can do your requirement i.e. Filtering the logical col. 'Y' on Reports.
    Else,
    2. See - Your Logical column 'Y' While creating log. column 'Y' make sure you use any expression builder to filter across Date column. (i.e. using any case statements or where clause).
    Else,
    3. Make sure your First Logical column comes from Table by default (i.e. Create the same col. in d/b so it would be your Physic col. )
    Thank you.
    Edited by: GRK on Jan 28, 2013 7:48 AM

  • Formatted Search in Pick & Pack Manage

    Hi,
    Was wondering if anyone could assist me to create a formatted search in the date range of Delivery/Due Date in the TO field ; only display the current date such as today.
    Cheers

    Liz,
    Your question is not very clear but to get todays date you can use this 
    SELECT GETDATE() and assign it to the Date field in the required form
    Suda

Maybe you are looking for

  • REST web-service invocation gives error ORA-29266: end-of-body reached

    We are trying to consume a REST web-service. We send county code and country name to the WS, it then inserts the data and sends us a response in XML. I used this PL/SQL code to invoke the rest WS. http://blog.warp11.nl/2011/07/calling-a-rest-webservi

  • Java.rmi.RemoteException

    Hi, I have a dc where am using the functionality 'export to excel'.For that i have used two other dc's 'dc_externallibray' and 'dc_serverlib' for accessing the jar files. I have added Jars_APIPublicPart,Jars_SDAPublicPart from dc_externallibrary and

  • Post manual/unplanned depreciation in previous period

    Dear Experts, I really appreciate for your advices on the following issue. I have posted depreciation up to period 9, 2010. However, there's an unplanned depreciation journal that was missed to be posted on period 8, 2010. Therefore, I tried to creat

  • IS it right using StringTokenizer in this case ...(pls see code& expl)

    Hi This project takes a comma delimited input file , where the values are in double quotes .The inputfile has more than 200 columns. ex: "12345","1","USA County School,Public","Rank1","TX","USA" if we observe the 3 rd column in the first record in th

  • Very Very Urgent!!!!Converting from Hijri To Gregorian Date

    Hi ABAP Gurus, Is there any  function module to convert the hijri date to Gregorian Date and vice versa. i have seen the code in one of the thread but it is not converting the hijri to gregorian dates accurately. Please help me to resolve the issue..