Date calculations...

Hello,
I need to figure out the date for next monday. Or, more precisely, I need to be able to get a Date instance (or Calendar instance) for the next day a given day (Calendar.SUNAY through Calendar.SATURDAY) occurs.
So if today is March 1 I need to be able to programatically figure out that the next day Calendar.MONDAY occurs is March 3. Also if today is at the end of the month (like Feb 28) it would need to know that next monday is March 3...
Thanks

public static Calendar nextOccurrence(int dayOfTheWeek) {
  Calendar cal = Calendar.getInstance();
  cal.roll(Calendar.DAY_OF_THE_WEEK, true);
  while(cal.get(Calendar.DAY_OF_THE_WEEK) != dayOfTheWeek) {
    cal.roll(Calendar.DAY_OF_THE_WEEK, true);
  return cal;
}

Similar Messages

  • Schedule Line Delivery Date Calculation with Transportation Scheduling

    Hi All,
    We are currently running into a problem where our Sales Order Schedule Line delivery dates are being pushed out too far into the future - because of the Calendar being used to determine the transit time.
    We have 'Delivery Scheduling' and 'Transportation Scheduling' activated for our Sales Document type
    We have Routes that are configured with a 'Transit Time' and a 'Factory Calendar'
    Order Scenario:
    'Factory Calendar' assigned to our 'Route' is setup with only one 'Workday' in a given week e.g. Wednesday
    Our 'Route' has a Transit Time of 2 days
    We create a Sales Order on Monday for a Material that is available in our Plant
    The 'Goods Issue' date is being determined correctly for the next Workday - being Wednesday
    The 'Delivery Date' is extending out over 15 days (2 Wednesdays into the future) - since it is working on 'Calendar Days' and not 'Actual Days'
    Does anyone know of a way (config or other) to only influence the 'Goods Issue' date with the 'Factory Calendar' assigned to the Route, and have the 'Delivery Date' calculated using the Transit Time on the Route and 'Actual Days' rather than Calendar days?
    All help greatly appreciated.
    Thanks,
    Ravelle<i></i>

    Hi Pathik,
    Thanks for your reply.  I have already maintained the Calendars I'm using for this business process in <SCAL> - same as <OY05>. 
    The problem I'm having though is that by assigning a Calendar directly to my route (which I doing to influence the goods issue date - using a 1 Working Day Calendar) it is also taking precedence in determining the Transit time - which in this case I don't want, as I want my Transit time to be determined using a 5 Working Day Calendar.
    I don't think this problem has a config option as a work around...I think the only possibility in this case is a development to achieve the results we need.
    Thanks,
    Ravelle

  • Date Calculation in BEx

    Hello All,
    In my report, User wants to see a day counter which is the dfference of a date (date coming from cube) and Current date. For current date  we are using 0f_aday sap exit. How we can we acheive this, does it involve any User exits at the back end or can I use a calculated keyfigure to find the difference between these two dates.
    Please reply to this as it is very Urgent Issue
    thank you

    HI AL,
    Thanks for the udpate. But I believe we can update any thread if its related with the same subject if its less than 3 years. Is it not right ? I have a mail in my inbox, from some moderator confirming the same. That is the reason I have updated this thread...as its related to the same question and this thread is created n 2011.
    Anyway, thanks for the answer. I will change the dimension to date and calculate the difference from the 2 variables.
    Reg another doubt, from the below link...
    https://docs.google.com/viewer?a=v&q=cache:YQS2jPhWysAJ:www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/705734f2-4e85-2e10-2ebf-891d0110de74%3FQuickLink%3Dindex%26overridelayout%3Dtrue+&hl=en&gl=au&pid=bl&srcid=ADGEESjL8dx81tAAJNL0Ln4c2MW4k3yZRDNFsop1pptOc3bQf1xU0Le9e3loFsZXJi5rWuYt3j7yoStGMktsL5XEdV9T3ONzdKay0x5yrIbaUBB3Dpz1Fr6xuggf_IZX-S0Q4WONpBhN&sig=AHIEtbTZfXXLN4gZCsw7qpZXgrkjeCYLcA
    what is the field used for Interval ( from, to , range) . You have missed my other question, why am I getting X below the result while doing the date calculation . I mean I am getting the result, but below every row, there is a X . Any ideas ?
    Thanks,
    DR

  • Due Date Calculation on A/R Invoice

    The Due date calculation on an Invoice for a customer with a payment condition of 30 days is wrong on  the system:
    Invoice DocDate: 11.05.17
    Invoice DueDate:  11.07.01
    On the BP Master Data is set a payment condition of 30 days. So it should be a due date of June, not July. This is a invoice that comes from a Sales Order with Approval Procedure.
    Our version is 2007 A SP:00 PL:49.
    Thanks in Advance...

    Hello,
    Perfect Notification
    For Payment Terms for Business Partner----
    IF (@transaction_type = 'A' Or @transaction_type = 'U')  AND @object_type = '17'
    BEGIN
    Declare @GroupNum as Nvarchar(20)
    Declare @OCRDGroupNum as Nvarchar(20)
    Declare @PaymentTermCode as Nvarchar(20)
    Declare @PaymentTermName as Nvarchar(20)
    Set @PaymentTermCode = (Select GroupNum from OCRD where CardCode = (Select CardCode from ORDR where DocEntry =@list_of_cols_val_tab_del))
    Set @PaymentTermName = (Select PymntGroup from OCTG where GroupNum = @PaymentTermCode )
    Set @GroupNum = (select GroupNum from ORDR where DocEntry =@list_of_cols_val_tab_del)
    Set @OCRDGroupNum =(Select GroupNum from OCRD where CardCode = (Select CardCode from ORDR where DocEntry =@list_of_cols_val_tab_del))
    If @GroupNum != @OCRDGroupNum
         begin
              SET @error = 10
              SET @error_message = N'Payment Terms Should be  ' + '   ' + @PaymentTermName + ' ' +' For this Business Partner'
         end
    END
    End----
    It will Definatillly Help You.
    Thanks
    Manvendra Singh Niranjan

  • Baseline date calculation

    Hi,
    We have a requirement to exclude non-Business days while calculating Baseline date(for the Accounting Document created on saving the Billing document)
    Currently the Baseline Date being populated in the Accounting Document is Document date + 5days(including Holidays).
    For eg
    Current Scenario
    Document Date: 12th Feb 2008
    Baseline date: 17th feb 2008.
    Requirement:
    Document Date: 12th Feb 2008
    Baseline date: 19th feb 2008(Excluding Sat & Sun).
    Request you to share useful info in this regard.
    Thanks
    Binu

    Hi,
    Use user exit RV60FUS5 for these base line date calculations.
    Thanks
    Krishna.

  • Baseline date calculation excluding non-Business days

    Hi,
    We have a requirement to exclude non-Business days while calculating Baseline date.
    Currently the Baseline Date being populated in the Accounting Document is Document date + 5days(including Holidays).
    For eg
    Current Scenario
    Document Date: 12th Feb 2008
    Baseline date: 17th feb 2008.
    Requirement:
    Document Date: 12th Feb 2008
    Baseline date: 19th feb 2008(Excluding Sat & Sun).
    Request you to share useful info in this regard.
    Thanks
    Binu

    Hi,
    Use user exit RV60FUS5 for these base line date calculations.
    Thanks
    Krishna.

  • Baseline date calculation in Invoice verification (MIRO)

    Dear experts,
    I need to set baseline date after 40 days from document date in MIRO.
    Baseline date calculation of "Terms of Payment" in IMG has two parameters:
      &#12539;Fixed day
      &#12539;Additional months
    We cannot set 40 days in these parameters.
    Can anybody tell me how to set baseline date not month but date(not fixed day) ?
    Please advise me on the settings SPRO>MM>Purchasing>Vendor Master>Define terms of Payment.
    Thanks & Regards
    Ken

    Hi,
    You can't do this.
    The baseline date is the date on which the calculations are made.
    So if you have 40 days to pay, this will be 40 days from the baseline date.
    This will either be the document date or another date, but you can't (in standard SAP) have the baseline date as "X" days after "Y".
    So the baseline date is the date of an event (e.g. the date that the Invoice was posted) not a calculation.
    Is it possible that you have misunderstood the use of this date?
    If you just want to ensure that the payment date is 40 days after invoice recipt, then set you just have to enter the number of days in the payment terms and the baseline date stays as the invoice date (etc.)
    Steve B

  • Baseline Date for Due Date Calculation required for S/L indicators

    Hello,
    Iu2019m facing the following problem
    Iu2019m trying to insert an invoice (using a customer master record) but the system blocks me because the field ZFBDT (Baseline Date for Due Date Calculation) is a Required entry.
    The strange thing is  that if I use a S/L indicators the field is mandatory, if not the date may be defaulted.
    I checked in OB41 but there are non differences between Special PK and normal PK.
    Any ideas?
    Thanks in advance
    Alberto

    Dear Alberto,
    the field "Due On (BSEG-ZFBDT)" cannot be controlled with field status.
    It is controlled by field attribute of screen painter (Tcd: SE51).  If
    you look at element attribute for "Due On" field, a flag for required
    entry is activated.  In this case, field status has no control over
    the field.
    As of release 3.1G, field BSEG-ZFBDT is hardcoded in most FI screens
    to be mandatory and cannot be influenced by any field status
    changes. This situation is only valid when posting with special G/L
    indicator (ie PK 29/39).
    SAP development team has determined that this is a critical field.  The
    reason behind this is that this special GL screen and the data entered
    here are very important to many other programs. This data affects
    liabilities and receivables where due date is necessary almost
    everytime. Thus, we changed this field in this screen in order to
    prevent problems in many other areas. The reason is explained further
    in note 95079.
    I hope this helps You.
    mauri

  • How is delivery date calculated

    How can anyone please explain how delivery date is calculated using forward and backward scheduling
    I want to have it broken down into the following steps
    for eg for delivery date calculation following dates are used
    Material Availabilty Date
    Material Staging Date
    Pick/pack time
    Transportation PLanning date
    Loading date
    Goods issue date
    Transit Date
    Delivery Date
    Can some one please give me an example and explain wht these dates are
    for eg customer needs delivery date on  11/20/2008
    how would the system cacluate whether it can meet the delivery date using backward scheduling
    and if it doesnt meet how does the system do the forward scheduling
    also i am not clear with the following dates
    material avaialibilty date
    material staging date
    transportation date
    can some one please explain me all this in detail
    Also i have another question at the sales order creation when is shipping point and route determined
    coz based on the ATP check only material avaialabilty date is determined and if we have a bacjground job running every 1 hours for atp then immediately when we create a sales order is a route and shipping point determined (just before we save the sales order)
    Let me be more clear
    Suppose customer representative recevies a order on the phone
    he enters sold to party, ship to party ,PO number,delivery date and material number and then hits enter
    so at tht time the shipping point and route is determined ?
    also when an atp check runs and if the delivery date is not met then the system will propose a new delivery date but if we have a different route configured say for eg overnight so we can meet the delivery date and we want to change this route to overnight what must we do?
    should we change the shipping condition in the header?
    I am not very sure about the process can you please also explain me this in detail?
    Thanks

    Hi there,
    When a sales order is logged & the user enters the requested delivery date, system 1st does the backward scheduling date. Pla note that the factory calender mentioned in the shipping point & route plays a crutial role in defining the working days & confirmed delivery date.
    For eg:  Customer has raised an order on 11/15 & requests delivery on 11/20/2008.
    the following times are important in delivery scheduling.
    Transit time: maintained in route
    Loading time maintained in the shipping point
    Transportation planing time maintained in the transportation planning point.
    pick pack time maintained in the shipping point.
    Material availability time maintained in MM02 --> MRP screens. This is the time that the material can be manufactured (for inhouse producted items) or external processing time (for externallly procured materials like TAS items).
    From the requested delivery date 11/20 system does the backward scheduling & determines the following dates:
    Goods issue date, loading date, pick pack date, transportation planning date & material availability date.
    Time between:
    goods issue date - reqested delivery date: transit time
    Goods issue date - loading date: loading time
    transportation planning date - pick pack date: picking pack time
    Material availability date - transportation date: transportation planning time.
    Consider that the factory calender has all days of the week as working dates (to make it simple to explain). Also transit time is 3 days, loading time is 1 day,pick pack time is 1 day, material availability time is 3 days.
    From 11/20 ussing backward scheduling system determines the following dates:
    Goods issue date: 11/17
    Loading date: 11/16
    Pick pack date: 11/15
    System will check if material is available on the 11/15 to start pick / pack. If it is available then system will confirm the reqested delivery date. Else it will check when the material is available. For eg basing on the MRP settings mnaterial is available only on 11/18. So from 18th system does forward scheduling & redetermines all the dates. So pick / pack date is 11/18. Loading date is 11/19, goods issue date is 11/20 & possible delivery date is 11/23. So system will confirm the delivery date on 11/23. This is when complete delivery is required. If partial delivery is allowed, then system will check how much quantity is available on 11/15. Accordingly it will give 2 delivery dates.
    In the above example include teh factory calender which will have 5 day week with Fri & Sat as holidays. Accordingly dates will change.
    Here replenishment lead time also plays an imp role. Pls refer http://help.sap.com/erp2005_ehp_03/helpdata/EN/6b/2785347860ea35e10000009b38f83b/frameset.htm for further information
    Regards,
    Sivanand

  • Dynamic Date Calculation for Current Date - 1

    I am trying to create a variant with a dynamic date calculation attribute.
    I am following the instructions as they are posted to the web but I get an error message.
    I want to get all data EQ to the current date -1
    In the object for selection screen I enter a D for Selection Variable, for Name of Variable I enter an I to include specific values and the option EQ for current date +/- ??? days.  Then I enter 1- for the number of days.  I have tried to enter this many times and in many ways but it doesn't work.  I keep getting this message "lower limit of interval is greater than upper limit"

    Hi,
    Welcome to SDN.
    Selection-screen has four values -
    SIGN
    OPTION
    LOW
    HIGH
    Pass your date value in the option low for the screen.
    Sign you have already pass as I and option as EQ.
    Regard,
    Amit
    Reward all helpful replies.
    Can you paste your code here.
    Message was edited by:
            Amit Khare

  • How to use Dynamic date calculation in some transactions.

    Hello everyone.
    I have to create some dynamic variants using the dynamic date calculation. The problem is that in some transactions it´s not possible to use some variables that can round a value. For example: in transaction /SAPAPO/MC90, I need to fix 3 months in the horizon like this: From date: 01.01.2009  To date 31.03.2009. The current month is 01.01.2009. Next month the current month will be february, so the horizon would be 01.02.2009 to 30.04.2009.
    In 5.1 version, it´s impossible to fix the months, because the options that appear in the match code are:
    Current Date
    Current date +/- ??? days
    current date +/- ??? work days
    First day of current month
    nth working day of current month
    First day of next month
    First day of previous month
    Last day of previous month
    Last Day of the Current Month
    Does anybody knows how to do this? This is happening in other transactions to.
    Thanks a lot
    Regards
    Angela

    I am not sure where you are looking for..but here is what I can do it in MC90 Tcode:
    1. when you try to save the variant, in the variant screen check the two boxes under "Current date" field for Selection Variables attributes "L"
    2. Then click on Selection variables option and click on the "D" variable so that it turns to green
    3. Drop down in the first current date field, select "Current +/- ??? days. here if you want to start from today's date maintain 0 days
    4. In the second Current date field maintain 90 days in "Current +/- ??? days.
    5. save it
    please let me know if I misunderstod the issue

  • Fiscal Calendar in Report Variant Dynamic Date Calculation

    We are switching from the standard calendar to a 4/4/5 calendar for our fiscal calendar. We have a number of batch reports that use dynamic date calculation in the variant to get Month-To-Date or Previous Month date ranges. Is there a way to convert these variants to use the new FiScal calendar instead of the regular calendar?

    thanks to answer , praveen.
    I know, VARI has name of FM , but not has Calendar ID.

  • Date calculation script

    Hi,
    I need to calculate difference between two dates. I believe that i should use function @DATEDIFF to perform such a calculation.
    But the problem that one of the dates calculated by such a script:
    i=@TODATEEX("Month dd yyyy",@CONCATENATE(@CONCATENATE(@NAME(@CURRMBR("Current Period"))," 01 "),@NAME(@ALIAS({RTP_Year}))));
    i=(@DATEPART(i,DP_YEAR)*100 + @DATEPART(i,DP_MONTH))*100+ @DATEPART(i,DP_DAY);
    This script returns first day of currently selected month and planning period (RTP_Year - financial year).
    And when i try to perfom calculation between variable i and member i ends whith error. Could you suggest something?
    I also tried some work arounds suggested in other threads but whithout success. I use 1.1.2.1.

    Hi,
    Try this:
    Re: Days behaviour between two dates
    Cheers,
    Alp

  • Data calculations in Indesign CS5

    I am wondering if there is a way to have indesign do date calculations. For instance, I enter a departure date for a trip into the document. The fine print in the document needs to have multiple dates filled in that are all a certain number of days before the departure day. 150 days before, 100, and 60. Is there a way to automate this?

    Javascript for InDesign has a Date object: http://jongware.mit.edu/idcs5js/pc_Date.html
    I guess you could use that to do the calculations. You could, for example, have a script that allows you to enter a date and then shows the list of prior-to dates, allowing you to copy them nto your document.
    Of course there is much more possible as well.

  • D: Dynamic date calculation

    Hello,
    In BEx, when creating a variant, is it possible to use "Selection variable = D: Dynamic date calculation"?
    I have created a variable for 0calmonth and in the Variant Attributes screen, Selection variable field, the only option is T: Table Variable from TVARVC.
    BW version 3.5
    Thanks for any information you can provide.
    Mark

    Hi,
    have a look at the below link..  ( they have mentioned the steps of customer exit variable fassigning for reporting agent)
    https://websmp110.sap-ag.de/~form/sapnet?_FRAME=CONTAINER&_OBJECT=011000358700003598422003E
    Regards,
    Siva.

  • Enable "dynamic date calculation" variable type

    When saving reporting date/period in a report variant, we may use "dynamic date calculation" to specific date as selection parameter.  But the "Dynamic date calculation" is not visible in some ABAP reports - only "Table Variable from TVARVC"  type is available for selection. 
    For those reports that are missing that variable type, how can we enable the "Dynamic date calculation" variable type to be visible?

    Hi Paco:
    Yes, they are z-reports, both have the same almost everything, created by the same ABAPer, for the same application SD, just grouping the data differently.
    It seems a screen (#100?) is missing,  In the old version, it's screen 100 where to activate the "D" and "B" variable types.  Now it goes to screen 281.
    Stacy

Maybe you are looking for

  • How to know how many users uses Report Designer?

    Dear Experts, Somebody knows if it's possible to know how many users have made look ups in Report Designer on one period or how many modifications? Thanks in advance.

  • Error when trying to create a directory in ASM

    Hello, I've got Oracle RAC 11gR2. Two nodes with Windows Server 2008. Database in ASM instance. I'm trying to create a directory "backupp" in ASM instance, but got error. All Oracle Windows services are running under Local Ssystem Account. I've logge

  • No action instance for path /SubmitStudentInfoAction could be created

    Hello all: I am facing the floowing exception when use the struts with websphere 5.1 [03/11/04 21:32:15:526 AST] 6eecc29a WebGroup I SRVE0181I: [StudentRegistrationWeb.war] [StudentRegistrationWeb] [Servlet.LOG]: action: Error creating Action instanc

  • Duplicating and incrementing a filename, and the same for text within

    I've done some work in AppleScript; not much in Automator. Am curious which might be the better hammer for this: Given an existing text file: ZAM001_001ref.mov (note: from job to job, only the "ZAM" portion will change). ... with a mime type of "vide

  • WAP2000 PoE/VLANs loosing Config

    Hello everybody, i have 4 WAP2000 configured with VLAN (sure one for management) connected to an linksys srw244g4p poe switch. I can configure the APs and even with the VLAN Setup they are working fine. I can access them connected to an trunk port an