How to update sales of last 3 months only

I have a query which basically updates the sales for the whole year, but i just want that one to be changed such that it only updates for the past 3 months,irrespective
of the year ( i mean to say if i run it today it must update march,april,may of 2014 but if i run it on jan 2015 then it must update oct,nov,dec of 2014).
Below is my update statement
update tODS_GLBalance
set tODS_GLBalance.tUTL_JobLogging_Key = @tUTL_JobLogging_Key,
tODS_GLBalance.Balance = vODS_GLBalance.GLAmount,
tODS_GLBalance.ModifiedDate = GETDATE(),
tODS_GLBalance.ModifiedUser = SUSER_NAME()
From ODS.Staging.vODS_GLBalance
Left Outer Join Ods.JJill.tODS_GLBalance
ON tODS_GLBalance.FiscalYearId = vODS_GLBalance.FiscalYearId
AND tODS_GLBalance.FiscalMonthOfYearId = vODS_GLBalance.FiscalMonthOfYearId
AND tODS_GLBalance.Page = vODS_GLBalance.PAGE
Where
tODS_GLBalance.FiscalYearId = YEAR(GETDATE())
AND
tODS_GLBalance.FiscalMonthOfYearId = vODS_GLBalance.FiscalMonthOfYearId
AND tODS_GLBalance.FiscalYearId = vODS_GLBalance.FiscalYearId
AND tODS_GLBalance.Page = vODS_GLBalance.Page
AND tODS_GLBalance.Balance <> vODS_GLBalance.GLAmount
Can someone please help me with this, Please let me know if you have any questions or if i am unclear.
Thanks

I suggest adding this line of code to the where clause:
AND
tODS_GLBalance.FiscalMonthOfYearId
in(month(dateadd(m,-1,getdate())),month(dateadd(m,-2,getdate())),month(dateadd(m,-3,getdate())))
This assumes that you are testing against the fiscalmonthofyear and that the fiscal periods are the same as calendar periods. Otherwise, there will be some adjusting to do.
This is basically checking to see if the fiscal monthofyearid is in the 3 most recent months.
/* If this helps, please click appropriately below. Thank you! */

Similar Messages

  • How to update photos in last 12 months. Photos are from June 2011-June 2012

    The photos in my smart folder titled "Last 12 months" are from June 2011 to June 2012. How do you update it to the current previous 12 months?

    in the iPhoto preferences change the las n months to a different number than 12 - close the preferences and then go back and set it to 12 again - this should do it
    LN

  • How to update Sales Order status using  BAPI_SALESORDER_CHANGE

    Hi,
    I want to update Sales Order status using BAPI_SALESORDER_CHANGE, this BAPI is called from middle ware, but there is no parameter to pass the status value to this function, please help me how to update sales order status using BAPI only.
    Thanks
    RK

    Hi,
    Can u give me details of what status u would like to update in sales order.
    If we are able to update the status from VA02, Then BAPI will assist for the same.
    Regards.

  • Sum sales query last 6 months

    Hi people......
    Using docdate and sum(quantity) how can i sum the last 6 months from today.??
    select itemcode, sum(quantity) FROM oinv, inv1, oitm, oitb.......   WHERE getdate()  ?????
    I hope explain correctly....

    Hi,
    Better use: DateDiff(DD,T0.DocDate,getdate()) >=  180
    Thanks,
    Gordon

  • How do I retrieve the last three months of diary info stored on my iPad, it has mysteriously dissappearedplease?

    How do I retrieve the last three months diary stuff as my iPad appears to have wiped the info off please help.

    Check Settings > Mail, Contacts, Calendars > [scroll way down to] Sync Events ...
    Set the time period as you wish.

  • For the last 3 months only, I am unable to complete my online payments on your website.  I get as far as method of payment, check the box, and click next.  Then nothing happens.  What gives.  I have to then pay by phone.  Just frustrating.

    For the last 3 months only, I am unable to complete my online payment on your website.  I get as far as Method of Payment, mark it, and then lick on NEXT and nothing happens.  What gives?  Have to pay it by phone.

    Sheesh. That looks hard. I think it will fall over at this point:
    "Connect to my Exchange mailbox using HTTP" 'cos Thunderbird uses only the regular email protocols: POP, IMAP and SMTP.
    Here (at work) we have in the past have had IMAP and SMTP enabled on our Exchange server so Thunderbird could then connect just like to any other regular internet-based service.
    With the change here to outlook365/outlook 2010 I've had to switch to using DavMail which lets Thunderbird talk to the mail server using OWA.
    I haven't (seriously) tried Exquilla. Whilst I have great respect for its author and some of his other add-ons, I saw no reason to use an add-on that required payment when DavMail works for free.

  • Customers without sales in last 6 months by sales group

    How would you get the customers that had not placed an order in the last six months by sales group?
    I was looking if in MCSI I could find something but no luck, I guess I will have to make a query on SQVI
    Regards,
    Carlos

    You need to create a Z-Report or manually download data into excel and compare.
    You need to sort out all customers based on sales group from table KNVV. Then check against orders created against those sales groups in last 6 months - the difference is te result.
    There are two points to be taken care of -
    1. All customers which was created in last 6 months but have not done any business - should be excluded from result
    2. If sales group is put/changed manually in transaction (i.e. customer and sales order sales groupd are different) then the logic will not work properly - Sales group wise.
    I had faced these problems in a similiar report, so just informing.
    Thanks

  • How to update sale order haeder conditions

    hi
    how to update header conditions using sale order bapi ' create from data 2'.
    regards
    Siva Shanmugam.A.V.

    u can use  'BAPI_SALESORDER_CHANGE'
    and see the following link
    http://abap.wikiprog.com/wiki/BAPI_SALESORDER_CHANGE
    Edited by: krupa jani on Nov 25, 2008 11:15 AM

  • Can someone help please tell me how to get rid of Last 12 Months?

            SOMEONE PLEASE HELP
    I really need help with how to delete the Last 12 Months on IPod Touch it is taking my space all up and I need help to delete my photos out of there.
    THANK YOU!!!!

    The iPhoto for iOS forum is here
    https://discussions.apple.com/community/app_store/iphoto_for_ios
    Regards
    TD

  • How to update sales orders using B1WS in SAP 8.8 PL18

    Hello all.
    We are having a problem updating sales orders using Sap Business One Web Service ( B1WS ).
    We are running SBO 8.8 PL18, MS-SQL 2008, and all is fine when using the SBO client.
    But when it comes to updating sales orders through B1WS we just cannot get it to work.
    We can add new orders easily without problems. Updating orders always gives this error:
    \[ORDR.PayDuMonth\]\[line: 0\] , 'Field cannot be updated (ODBC -1029)'
    We have checked and verified multiple times that our setup is correct.
    Also the WDSL files are verified.
    We can update orders just fine using the sboclient.
    And using B1WS we can basically do everything, besides updating.
    We have also tried this on different company db's, so we are quite sure this is not
    something related to some general setting we missed, but who knows?
    We have tried different ways to "assemble" the order before updating, but it always
    ends with the above error.
    Here is an example of one of the tests, where we load an order by docentry,
    increment the quantity of all open lines by '1', and then try to update it.
            protected void Page_Load(object sender, EventArgs e)
                // First we login
                string sessionId = "";
                LoginService.LoginService l_login = new LoginService.LoginService();
                LoginService.LoginDatabaseType l_dbtype = LoginService.LoginDatabaseType.dst_MSSQL2008;
                LoginService.LoginLanguage _lang = LoginService.LoginLanguage.ln_English;
                string _server = "SAP-8_8PL18";
                string _licserver = "SAP-8_8PL18:30000";
                string _db = "my_test_company";
                string _user = "manager";
                string _pass = "********";
                try
                    sessionId = l_login.Login(_server, _db, l_dbtype, true, _user, _pass,
                               _lang, true, _licserver);
                catch (Exception ex)
                    Response.Clear();
                    Response.Write(ex.Message);
                    Response.End();
                if (sessionId == "")
                    Response.Clear();
                    Response.Write("No sessionId");
                    Response.End();
                // We are logged in and have a sessionId
                // Now load a valid open order by docentry
                try
                    OrdersServiceRef.OrdersService orderService = new OrdersServiceRef.OrdersService();
                    orderService.MsgHeaderValue = new OrdersServiceRef.MsgHeader();
                    orderService.MsgHeaderValue.SessionID = sessionId;
                    orderService.MsgHeaderValue.ServiceName = OrdersServiceRef.MsgHeaderServiceName.OrdersService;
                    orderService.MsgHeaderValue.ServiceNameSpecified = true;
                    OrdersServiceRef.DocumentParams docParams = new OrdersServiceRef.DocumentParams();
                    docParams.DocEntry = 31; // Docentry of a known open order
                    docParams.DocEntrySpecified = true;
                    OrdersServiceRef.Document order = orderService.GetByParams(docParams);
                    OrdersServiceRef.DocumentDocumentLine line = null;
                    for (int i = 0; i < order.DocumentLines.Length; i++)
                        line = order.DocumentLines<i>;
                        if (line.LineStatus == OrdersServiceRef.DocumentDocumentLineLineStatus.bost_Open)
                            line.Quantity += 1;
                    orderService.Update(order);
                catch (System.Web.Services.Protocols.SoapException ex)
                    Response.Clear();
                    Response.Write(ex.Message);
                    Response.End();
                catch (Exception ex)
                    Response.Clear();
                    Response.Write(ex.Message);
                    Response.End();
                Response.Clear();
                Response.Write("All OK");
                Response.End();
    I hope that someone has an idea as to why this happens.
    The customer often changes quantity or adds lines on their orders,
    and the only way to solve it so far has been to make a new order and
    close the old one.
    Thanks in advance
    J. Thomsen

    Hi,
    Welcome you post on the forum.
    Have you checked if you only update a specific line instead of a loop?
    Thanks,
    Gordon

  • How can i get the last 2 months history?

    I want to get the call history of the last 2 months. Unfortunatelly iphone restore only the last 100 phone calls. Is there a way to retrive all phone calls from the last 2 months?

    The best way is to contact your carrier for an itemised bill.

  • How to update Sales Order Delivery Block while saving Delivery ?

    Hi,
    I have a requirement wherein i need to update sales order delivery block field(VBAK-LIFSK) while saving the delivery for the order.
    Also I need to remove this block while execution of  Backorder Rescheduling program SDV03V02 (Tcode : V_V2),
    Can anybody help me out in this?
    regards,
    Nitin

    HI,
    try using BAPI_SALESORDER_CHANGE
    pass ur vbeln in SALESDOCUMENT
    pass an 'X' to    BAPISDH1-DLV_BLOCK
    and 'X' to        BAPISDH1X-DLV_BLOCK
    Also add the UPDATE task clause, you will want to set the flag only when delivery is being saved, not before that.

  • How to compare sales of 2 dates with only one date is given?

    I am having a requirement such that the user wants to see the particular company Y2D sales of this year and previous year, and only one variable selection is given (today's date). How can i design the report to see this year sales and last year sales in separate columns?

    Hi ,
    You have to create two RKFs.
    In the first RKF , you have to create a customer exit variable on your date and that too it should be interval . Using the CMOD code , populate this interval from the 1st day of this year till the date user is entering .
    In the second RKF , you have to create a customer exit variable on your date and that too it should be interval . Using the CMOD code, you have to populate the interval from the 1st day of the previous year till the same date as entered by user but it should be of last year .
    You have to write the above 2 codes in I_STEP = 2 mode .
    Hope the above reply was helpful.
    Kind Regards,
    Ashutosh Singh

  • IPhoto "Last 12 months" only shows 1 month from March-April

    On August 24th I imported some film into my iPhoto. Well I finally have a chance to go edit it and it is not there. After searching for it on iPhoto and my computer and an external hard drive- all just in case- I discovered that my iPhoto will only open up photos/video from 3/20/13-4/27/13. It says that that is what I uploaded in the last 12 months...I have uploaded a lot more than that and used it to create videos and export photos from my iPhone.
    I can't find my videos anywhere and it is for a project due on Monday.
    Can anyone help?

    Wondering: what happens to photos in the Last 12 Months folder, which have not been sorted into other albums, after 12 months..? -
    Nothing happens to them. The last twelve months album is just a window, showing you a current selection of your photos.  You can access all photos in your library either from the Photos view or from the "events" view. Each photo is a member of one of the events.
    You can define your own "last xxx month" albums with a different date range by defining a smart album from the File menu.
    Format the date according to the date format in your region settings.

  • How to update sales order number (KAUFN) characteristic in the profitability segment of the PA document created at the time of service entry sheet confirmation, as a result of shipment cost document

    Hi,
    We have a scenario wherein we create shipment cost documents against delivery. As a result of shipments fully transferred, a PO for freight vendor is automatically created and a service entry sheet confirmation happens. As a result of service entry sheet confirmation, we have Financial accounting, Controlling and profitability analysis documents created. We have a requirement wherein we need to have the characteristic “sales order number (KAUFN)” populated in the profitability analysis document created as a result of service entry sheet confirmation.
    Could someone please advice how could this be attained in COPA. Thanks for your help in advance.
    Regards,
    Sandeep

    Hi Ajay,
    Thank you for the quick update.
    The document is updated to COPA through OKB9 settings. The profitability segment is updated with fields like customer, product, company code, plant, sales area data, profit center, etc; however the sales order number is missing.
    Could you please elaborate further how could FI substitution be implemented to call for the FM COPA_PROFITABILITY_SEGMENT through user exit? Are you recommending the substitution through GGB1? What could be the possible validation to call for the user exit to be implemented?
    Regards,
    Sandeep Kulkarni

Maybe you are looking for

  • Changes are not getting reflected in Process Chain after changes.

    Hello, I have modified a Process Chain in Development environment. I have created one new infopackage and included it in the process chain. I have also added two new change run variants in the process chain. I have collected the process chain and inf

  • Does exporting DV using "Match Sequence Settings"

    I am capturing VHS and Hi8 home video using a Canopus ADVC-300 and Premiere Pro CS6.  The output is DV, about 14GB/hour.  Most of the captures are unattended (have a 4 TB disk, backed up of course, but space is not a big concern right now).  I'd like

  • Can't open the itunes

    Everytime i try to open the itunes, i receive the message "itunes has stopped working". I don't know what is going wrong here. It's work fine before i upgrade it to the 7.6 version. I try to uninstall and reinstall the itunes again and try every sing

  • Transactions Routing randomly to the incorrect bpel processes..

    Hi, We are having a design scenario in B2B and BPEL Integration as mentioned below: 1. For a given Business Action defined in B2B , for a given revision ---Business Protocol : EDI X12 over Generic Exchange ---Document Protocol EDI_X12 -- we have a gi

  • Page Processes and Branches.. what am I doing wrong?

    Need a bit of help with page processes (or suggestions for a better way to do something). I have an Apex page which does the following when you click a button - 1. Imports a CSV file into an Oracle table by calling a SQL Loader process 2. Calculates