Number of occurences between two dates based on a starting date + frequence

I have a starting date in cell A1 and a frequency (in days) in cell B1. In cell C1 I have a date (begin) and in cell C4 I have a later date (end). I need to know how often the event occurs during the time between begin and end dates (inclusive).
For instance, the starting date is january 25th, the frequency is 5. The first date is januari 25th, the second date is februari 12th. The result should be 2 (because given the starting date and frequency of the event, it will occur in februari on day 4 and 9).
I have been looking at some of the statistical functions, but I don't think there is a function for this. Right now I have about 5 formulas to calculate intermediate results, but I'm stuck trying to combine them.
I would be happy with just a pointer in the right direction. For instance, is there a specific name for this kind of calculation?

michielvoo wrote:
I have a starting date in cell A1 and a frequency (in days) in cell B1. In cell C1 I have a date (begin) and in cell C4 I have a later date (end). I need to know how often the event occurs during the time between begin and end dates (inclusive).
For instance, the starting date is january 25th, the frequency is 5. The first date is januari 25th, the second date is februari 12th. The result should be 2 (because given the starting date and frequency of the event, it will occur in februari on day 4 and 9).
If the event occurs every five days, the second date will be January 30, and the event will occur four times " during the time between begin and end dates (inclusive)"
I have been looking at some of the statistical functions, but I don't think there is a function for this. Right now I have about 5 formulas to calculate intermediate results, but I'm stuck trying to combine them.
It's not really a statistical calculation, but a simple division to find "How many whole sets of five (days) are there in the days between two dates."
I would be happy with just a pointer in the right direction. For instance, is there a specific name for this kind of calculation?
Two functions and one operation are needed:
DATEDIF() to calculate the number of days between the start and end dates.
Division to determine how many sets of five days there are in that period.
INT() to discard the fractional part of the result.
With the values located as described, this formula (placed in a cell on the same table) will return the number of occurrences not including the first one.
=INT(DATEDIF(C1,C4,"D")/B1)
To include the Start date as one of the occurrences, make this modification:
=INT(DATEDIF(C1,C4,"D")/B1)+1
Regards,
Barry

Similar Messages

  • I wanted to know how do you calculate the number of days between two dates

    i wanted to know how do you calculate the number of days between two dates in java ? i get both the dates from the database. i guess there are many issues like leap year and Febuary having diff no of months ..etc.

    thanks..
    I solve my problem as
    public class MyExample {
        public static void main(String a[]) {
            String stdate = "2009-03-01";
            java.sql.Date currentDate = new java.sql.Date(System.currentTimeMillis());
            java.sql.Date preDate = java.sql.Date.valueOf(stdate);
            System.out.println(currentDate);
            System.out.println(preDate);
    //        int dateCom = preDate.compareTo(currentDate);
    //        System.out.println(dateCom);
            long diff = currentDate.getTime() - preDate.getTime();
            int days = (int) Math.floor(diff / (24 * 60 * 60 * 1000));
             System.out.println(days);
    }

  • How to Calculate number of months between two dates

    Hi All,
       In one of the fomr developments, I have to calculate the
    Number of Days
    Number of Months ( Considering Leap Year) provided by the dates, end user enters in the form,
    After going thorugh some forum discussion, I have come to know about so many things which were not clear till now.
    I have gone through various forums too,  some one suggets to make use of FORM CALC and some other JAVA SCRIPT. But the logic i want to build in java script.
    The most interesting point is the DATE object is not getting created when i write  the below code
      var startDate = new DATE(oYear, oMonth, oDay);
    I am still not clear, that really the date object gets created in Adobe form If so the why the alert box is getting populated when i write below lines
    var oTemp = startDate.getFullYear();
    xfa.host.messagebox(oTemp);
    So, there are so many unclear things,
    If any one can help me by suggesting the approach and how to build the logic in the JavaScript I would be really thankful
    Regards
    PavanChand

    Hi,
    ChakravarthyDBA wrote:
    Hi
    I want number of Sundays between two dates
    example
    number of Sundays count between '01-04-2013' and '30-04-2013' in one select query I have to include this as sub query in my select statement.Here's one way:
    SELECT       early_date
    ,       late_date
    ,       ( TRUNC (late_date + 1, 'IW')
           - TRUNC (early_date,        'IW')
           ) / 7       AS sundays
    FROM       table_x
    ;This does not depend on your NLS settings.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Point out where the statment above is getting the wrong results, and explain, using specific examples, how you get the right results from the given data in those places.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • How to count number of sundays between two dates

    Hi
    I want number of Sundays between two dates
    example
    number of Sundays count between '01-04-2013' and '30-04-2013' in one select query I have to include this as sub query in my select statement.

    Hi,
    ChakravarthyDBA wrote:
    Hi
    I want number of Sundays between two dates
    example
    number of Sundays count between '01-04-2013' and '30-04-2013' in one select query I have to include this as sub query in my select statement.Here's one way:
    SELECT       early_date
    ,       late_date
    ,       ( TRUNC (late_date + 1, 'IW')
           - TRUNC (early_date,        'IW')
           ) / 7       AS sundays
    FROM       table_x
    ;This does not depend on your NLS settings.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Point out where the statment above is getting the wrong results, and explain, using specific examples, how you get the right results from the given data in those places.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • Get number of hours between two dates and two hours using factory calendar

    Hello all,
    I have the following requirement: I need to calculate the number of hours between two dates and two hours (start date- finish date and start hour-finish hour) or timestamps using a factory calendar. I must program it on CRM environment.
    Does anybody know a function module that makes it?
    Thanks in advance.
    Carmen

    Please check function module DURATION_DETERMINE.
    - April King

  • Find Exact number of days between two dates

    How can get the exact number of days between two dates?

    An example of business days calculation in SQL */
    /* The algorythm is: */
    /* 1) Take the absolute difference between the dates */
    /* to_date('&todate') - to_date('&frdate') */
    /* 2) Subtract the weekends (number of weeks in the range */
    /* TRUNC(to_date('&todate'),'D') = 1st day of week that */
    /* end of period is in */
    /* TRUNC(to_date('&frdate'),'D') = Last day of week that */
    /* start of period is in */
    /* So subtracting these two gives the number of days */
    /* between the two dates but including all of the days in */
    /* the weeks that the dates start and end in. When this */
    /* number is divided by 7 it gives the number of weeks. */
    /* Multiplying by 2 gives the number of weekend days.     */
    /* 3) Subtract 1 day if the ending date is on a saturday */
    /* DECODE(to_char(to_date('&todate'),'D'),7,-1,0) */
    /* --> If the day of the week is saturday (7), returns -1 */
    /* 4) Subtract 1 day if the start date is on a sunday */
    /* DECODE(to_char(to_date('&frdate'),'D'),1,-1) */
    /* --> If the day of the week is sunday (1), returns 1 */
    /* 5) Add one day to make the range inclusive (The '1 + ' ) */
    /* Author: Kenneth Atkins ([email protected]) */
    /* http://www.olywa.net/katkins/oratip */
    define frdate = '&1'
    define todate = '&2'
    set verify off
    select      
         '&frdate' From_Date
         ,'&todate' To_Date,
         1 + to_date('&todate') - to_date('&frdate') -
         ((TRUNC(to_date('&todate'),'D') - TRUNC(to_date('&frdate'),'D'))/7)*2
         + DECODE(to_char(to_date('&todate'),'D'),7,-1,0)
    + DECODE(to_char(to_date('&frdate'),'D'),1,-1,0) Business_Days
    from dual
    Here is an example of running the script:
    SQL> @busdays 01-AUG-96 15-AUG-96
    FROM_DATE TO_DATE BUSINESS_DAYS
    01-AUG-96 15-AUG-96 11

  • Number of sundays between two dates

    Hii ,
    How can I get number of sundays between two dates...?
    Plz help me in this regard
    Shoaib rehman

    *& Report  ZEX1
    REPORT  zex1.
    DATA :       p_low TYPE d ,
                      p_high TYPE d .
    DATA : gv_scnt TYPE i.
    p_low  = '20100115' .                                       "feb 1
    p_high = '20100228'.
    IF p_high > p_low.
      PERFORM cal_sundays USING p_low .
      WRITE :/ gv_scnt.
    ELSE.
    *             message date combination invalid
    ENDIF.
    *&      Form  CAL_SUNDAYS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM cal_sundays USING p_low ."changing gv_scnt.
      DATA : lv_week TYPE scal-week,
             lv_sund TYPE d,
             lv_mond TYPE d,
             lv_scnt TYPE i.
      DO .
        CALL FUNCTION 'GET_WEEK_INFO_BASED_ON_DATE'
          EXPORTING
            date   = p_low
          IMPORTING
            week   = lv_week
            monday = lv_mond
            sunday = lv_sund.
        IF p_low > p_high.
          EXIT.
        ELSE.
          gv_scnt = gv_scnt + 1.
          p_low = lv_sund + 1.
          PERFORM cal_sundays USING p_low.
        ENDIF.
      ENDDO.
    ENDFORM.                    " CAL_SUNDAYS
    Execute this and check if this meets ur case . Logic should be something like this .
    Br,
    Vijay.

  • How can i get number of days between two dates represented by two dates?

    how can i get number of days between two dates represented by two date objects. One is java.sql.Date, the other is java.util.Date?

    tej_222 wrote:
    But how do I do that conversion. from java.sql.date and java.util.date to calender?
    -thanks for the quick response.You may find the following utility code samples useful:
    [http://balusc.blogspot.com/2007/09/calendarutil.html]
    [http://balusc.blogspot.com/2007/09/dateutil.html]
    ganeshmb wrote:
    (date1.getTime() - date2.getTime())/(1000*60*60*24) should do.
    getTime returns millsecond value of date object and the difference divided by no of milliseconds in a day should fetch you the difference in terms of days.This doesn't respect the DST. Use java.util.Calendar.

  • Count the number of records between two key values (BTREE)

    How can I count the number of keys between two values?
    I'm using python driver, and BTREE access method.
    ====>
    ideally what I want is to average a whole time-series data set (the intervals can change) to a given number of points. The keys are the time stamps and the values are the data that needs to be averaged. I need to count the number of records between two time stamps so that I can divide that number by the number of points i need, and average the data. What is the best way to do this?  Or should I just keep the intervals for the time stamp constant and use RECNO access method?
    Thank you
    (first post btw.. and why aren't there many people in stackoverflow who answer Berkeley DB questions?)

    BDB is an embedded db and it does not have any internal counters or statistics that you could grap to use for this.    You will need to do it manually.
    You can create a cursor, grap the records you want, each time you get the next record you bump a counter.
    If you are using RECNO, you can use a cursor to get the record number of the record (DB_GET_RECNO), and if all you data is in
    sequentail records with no missing records you can figure out the total count by take last rec # - initial rec # + 1 to get a total count.
    If you switch over to the SQL API, you can issue a SQL query to give you a count.  Select count(*) Where .......
    Since you have to grab the data anyway, then best may be to count records as you go along.
    thanks
    mike

  • Shareable Interface between two RMI based applets

    Hello! I am developing a project in simulation environment (cref) in Java Card and I have one problem.
    First of all I have create two RMI based applets and I want to make one of these applets to implement a shareable interface.
    As we know a classical RMI based applet has three parts: one interface that extends Remote interface (lets call it ApplicationRemoteInt),
    one class that implements the previous interface (ApplicationImpl) and one class that extends javacard.framework.Applet which manipulates
    ApplicationImpl (ApplicationApplet).
    My problem is that I don't know which of these three programs (make it two, I don't think i could be
    ApplicationRemoteInt) have to implement an another Interface, which extends Shareable Interface (ApplicationShareable), and in which way.
    Also I think that the ApplicationShareable must be implemented by an Applet class.
    As you see I am confused, can anyone help me, please?
    Thank you in advance, Bill.

    Thank you very much for your response. I had knowledge about Shareable Interfaces between two traditional applets,
    BUT not between two RMI based applications.
    Finally I found that RMI based application does not support shareable interface:
    http://forum.java.sun.com/thread.jspa?threadID=728540&messageID=4194658
    Thank you for your reply anyway, Bill.

  • Function module to give a date based on a particular date and interval.

    Hi there,
    I am writing a code where I need to to find another date
    based on a key date and and an interval.
    Is there any function module where I pass the date and the interval
    (say 30) and it gives me a new date after subtracting 30 from it.
    Or is there any piece of code which does it?
    Thanks in advance.
    Regards,
    Kate

    hi Kate,
    you can try ?
    data : date2 like sy-datum.
    date2 = yourdate - 30.
    hope this helps.

  • Determine number of weekdays between two dates

    I have LiveCycle 8.0 ... I have a form with two date fields called "FirstDayOff" and "LastDayOff". I want to determine the number of weekdays between those two dates and then convert to number of workday hours (based on an 8 hour day) ... I am using this for a "time off" request sheet for my company ...
    Also, can I use Formcalc to automatically give me the previous weekday to "FirstDayOff"
    Thanks.

    I have LiveCycle 8.0 ... I have a form with two date fields called "FirstDayOff" and "LastDayOff". I want to determine the number of weekdays between those two dates and then convert to number of workday hours (based on an 8 hour day) ... I am using this for a "time off" request sheet for my company ...
    Also, can I use Formcalc to automatically give me the previous weekday to "FirstDayOff"
    Thanks.

  • How can I calculate the maximum number of days between two dates in a range of dates?

    I have a column of dates spanning the couse of a few months.  I would like to know if I can calculate the maximum number of days between each row and display the highest number.  I currently have another column that calculates the days betwen the rows and I am currently just looking at the totals and highlighting the highest period.
    Is this possible?  Any help or suggestions are appreciated.
    Thank you,
    Trevor

    This sounds totally possible,  Can you post a screen shot of your table to make responding more focused?  If you mean you want to:
    A) compute the difference (in days) between two date in the same row, then
    B) find the max duration (in days)
    Here is my take on this problem:
    D2 = C2-B2
    select D2 and fill down
    F1=MAX(D)
    to perform the conditional formatting (to highlight the max duration) select column D, then set up conditional formatting as shown in the 1st image

  • How to calculate number of days between two date in Template design?

    Hello guys
    I have a situation where I have to create a template that returns data, and one of the thing of the existing report is that there is a column that is actually the number of days between start date and end date columns..
    So in template, how would I be able to do the same? I have start date and end date columns on the template, now when I created another column using expression like end date - start date and preview the template, I am getting errors saying :
    Caused by: oracle.xdo.parser.v2.XPathException: Cannot convert 03/31/2009 to number.
         at oracle.xdo.parser.v2.XSLStylesheet.flushErrors(XSLStylesheet.java:1534)
         at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:521)
         at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:489)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:271)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:155)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:192)
    Please advice
    Thanks

    Hi
    There is an extension function you can use, from the javadoc:
    date_diff
    public static long date_diff(java.lang.String format,
    java.lang.String fromDate,
    java.lang.String toDate,
    java.lang.String locStr,
    java.lang.String tzID)
    Method to get the difference between two dates in the given locale. The dates need to be in "yyyy-MM-dd" format. This function supports only Gregorian calendar.
    Parameters:
    format - the format to which the difference is required; allowed formats are y (for Year), m(for month), w(for week), d(for day), h(for hour), mi(for minute), s(for seconds) and ms(for milliseconds)
    fromDate - the first date
    toDate - the second date
    locStr - locale string -> lang-Territory
    tzID - timezone ID ->http://java.sun.com/j2se/1.4.2/docs/api/java/util/TimeZone.html
    Returns:
    the difference in dates in the desired format
    For example
    <?xdoxslt:date_diff(‘d’,’2009-09-14’, ‘2009-09-20’,’en-US’,1)?>
    give a result of 6
    You can substitute in columns for the dates, just remember the date format required.
    Regards
    Tim

  • Number of days between two dates

    I have two dates-String Date1, String Date2(format of both the dates is 'DD-MM-YY'eg;'28-Jan-2008'). I want to find the difference between these dates;ie if value of String Date1 is '28-Jan-2008' and value of String Date2 is '28-Jan-2009', I need to find the number of days between these dates. What need to be done? Can anyone help me out please.
    Thanks in advance for all the help.
    Regards,
    Anees

    Doing a search is a bit ineffiecient. I'd take advantage of the fact that dates are acually stored in milliseconds. Subtract the two millisecond values (Data.getTime()) and divide by the number of milliseconds in a day. One complication, though, is daylight saving time but if you round rather than truncate in the division it should be fine.
    private static final long MILLIS_PER_DAY = 24L * 60L * 60L * 1000L;
    int dayDiff = (int)((date2.getTime() - date1.getTime() + MILLIS_PER_DAY/2)  / MILLIS_PER_DAY);

Maybe you are looking for

  • How do I change the folder that Photoshop gets my presets from?

    First and foremost, I'm using Photoshop CS6, and I'm running Windows 7. I have a boatload of presets (brushes, styles, custom shapes, et cetera). I'm currently running Photoshop from a second, internal hard drive which has more space. Currently, Phot

  • My Toshiba external hard drive won't mount after OSX Mavericks update. Please help.

    Two days ago I updated to Mavericks 10.9.3 and prior to this, my Toshiba 1TB external hard drive worked perfectly well. Since the update, my hard drive will no longer mount. It shows up in Disk Utility but will not let me 'mount', 'verify disk' or 'r

  • Create Hyperlink in Excel

    Hi all, I looked through the excel examples that ship with labview. I found out how to get data into excel cells and read from them. But I still look out how to create a hyperlink that is connected to a text in an excel cell. I think this could be do

  • Some problems after update!

    I've updated my iphone 5s to 7.0.6 version of IOS. and after the update i didn't receive push-notifications from facebook. how can i fix it??? Здравствуйте.. После последней прошивки (7.0.6) на телефон перестали приходить пуш уведомления от фейсбука

  • Getting Error with the C++ code

    I have a function in C++ which accepts a "jstring". And if i write the below line of code it gives me error. jsprData -> is the jstring INPUT char sprData = (env)->GetStringUTFChars(env, jsprData, 0); But the same thing if i write in a "C Code" and b