How to "select" sth which takes place every n days?

Hi there,
I'm developing a JSP/Servlet-based event calendar for young people in a big German city. I recently ran into a problem while implementing a new feature requested by the team which is maintaining the website. Editors can enter events over a web-based form; currently supported are events which take place on a single day or spawn over multiple days.
I've been asked to provide means of entering something like events which take place every n days, starting at a given date.
I thought about storing the start date and an integer which holds the number of days after that the event should take place again. This would be very easy to implement on the frontend: A textfield/dropdowns for the date and a textfield/dropdown for the "repeat every n days" thing.
But I can't think of any reasonably fast way to get those events from the database when my servlet should display all events between, let's say, December 1 and December 24.
The only thing which came to my mind was selecting every event's start date, taking the "repeat every n days" field an check if the current date is one of those "repeat days" by repeatedly adding the "repeat every n days" value. But this would seriously affect the servlet's performance. Let me explain the above idea with some pseudo code:
ResultSet rs = stmt.executeQuery("SELECT * FROM events ...");
while (rs.next())
Date startDate = rs.getDate(...);
// don't care about the single-day and multiple-day events here
int repeatEveryNDays = rs.getInt(...);
while (startDate <= currentDate)
if (startDate.equals(currentDate))
// show event on search results page
else
// increase date by "repeatEveryNDays"
startDate.day += repeatEveryNDays
}As I knew this forum very well, let me emphasize that this is not some kind of homework assignment. If you want prove, go to http://www.under18.de and look at the site. But I doubt that will keep the trolls away from this topic :(
Thanks for your ideas,
Philipp
PS: For those not so capable of understanding what some call German g, here's a Googled translation into English (ahem... ignore the text, it's colloquial German and Google doesn't seem to like it): http://translate.google.com/translate?u=http%3A%2F%2Fwww.under18.de&langpair=de%7Cen&hl=en&ie=UTF-8&oe=UTF-8&safe=off&prev=%2Flanguage_tools

I just thought about this one: Assume I have an event
starting on Nov 2 taking place every 7 days. Now I'd
search for events between Nov 3 and Nov 11. The
difference of start date - STARTDATE would be
1, divided by 7 would be 1/7 (about 0.142857).
Adding 1 to 0.142857 would be rounded to 1 (using
integers), resulting in Nov 4 if I'm right. Well, Nov
4 falls between start date and end date
but there actually is no event on Nov 4 according to
the 7-day period defined above. I don't get any
further with your "calculate the next event based on
that number plus one".Taking your example, the difference between start date and STARTDATE is 1 day, which means that the first event is after start date. Now the first occurrence that is after start date is (0+1)*7+STARTDATE, which is (Nov 2 + 7).
All you have to do with this number is to make sure it isn't after the ENDDATE value (to verify it is in your repeating schedule), and doesn't fall after the end date that you are comparing for.
Some math major can probably explain the calculation better than I have, but the basic idea is figure out what the first occurrence is that is after your start date and then make sure it's not greater than end date.

Similar Messages

  • How can I stop (the annoying) McAffee Antivirus from downloading every time Adobe Flash needs to upate (which lately is every second day)

    How can I stop (the annoying) McAffee Antivirus from downloading every time Adobe Flash needs to upate (which lately is every second day)

    don't auto update.  manually update and untick mcaffee.

  • HT5731 I purchased doc mcstuffins on the iPad. Downloaded several times which takes at least a day to do. Still unable to view episodes. Akers for a frustrated mommy & 3yr old. Did I just waste $30????

    I purchased doc mcstuffins on the iPad. Downloaded several times which takes at least a day to do. Still unable to view episodes. Akers for a frustrated mommy &amp; 3yr old. Did I just waste $30????

    El3ees wrote:
    I will be taking my laptop in on monday morning again and im assuming i will be waiting for another 4 weeks maybe more.
    Don't take your laptop back. Find out the number for Apple Care in your part of the world and call them. Tell your story to them. If the person on the phone can't help you, ask for their supervisor. Keep asking for supervisors until you get exactly what you want to get. If that mean you want to get the problem fixed without having the computer gone for four weeks, then keep asking for supervisors till you get someone who can do that for you.
    Be prepared to be on the phone for a while, so arrange a speaker phone, water to hand etc. Be patient.
    As for "crappy computers"--my MBA has worked flawlessly since the day I got it. As good if not better than any Apple laptop I've ever had, and I've had several.This is the thing though, there is a percentage of failure rate that occurs in electronics. It occurs whether we're talking about televison sets or toasters. If it's electric, it has that failure rate. Now sometimes a thing will be bad and in that case the word gets out and everyone knows that particular electronic has surpassed the normal failure percentage. The Airs, however, have not done that. Their reputation, so far, has been incredibly solid and good. So you can assume that you, unfortunately, got one out of that small percentage of electronics that have an issue.
    Laptops, let us remember, are doing a lot in a very small area. A lot can go wrong, and it's pretty amazing how many don't, especially given how many are made and sold. Sometimes we get the bad apple in the barrel, it doesn' t mean that the company making it has gone down hill. We hope the manager of the store, or the company, or someone will do right by us. If they don't, then we need to make sure they do. Keep asking for upper management till you get what you want.

  • How can I generate automatic inspection lots every 15th day

    Hello,
    My client receives chemicals (Raw Mat) every day. Incoming inspn is done only for physical spec and Usage deciison is taken on same day itself.
    As he is getting raw mat from good vendors, he usally do chemical analysis every 15th day.
    Whats the best way for me to map this process of generating inspection lot on every 15 day. initial incoming lot we cant use as he already taken UD on that.
    15 day chemical analysis dont have any impact on qty posting as Raw mat usally will be consumed.
    Is there anything other than manual lot. I welcome all ideas.

    In this case your looking at a pooled sample of the approx. 15 batches of material that were received in.  Correct?
    If you are batch managed, then no.  Since the sample is a composite sample, you can't link it to anything else really and you don't have a batch number to enter into the inspection lot upon creation.  First, you'd have to create a dummy batch to hold the results.  Which you could do maybe by date if your system allows external batch numbering.
    Then you could at least manually create the inspection lot.
    The is no true "event" to trigger the creation of the inspection lot as there is when you do a GR.  The only why you could trick the system would be if your were willing to maintain a separate storage location, and do a stock posting to it of the sample quantity each day.  Then you could have an inspection plan that would create a skip lot each day.  On the 15th day it would become required.  You would probably utilize a copy of movement type 411 for this and use that custom one to make the moves. 
    The problem with this is then you'll have to write off that little bit of material at some point for accounting purposes.
    Another option.. you could create dummy batch and set a 15 day inspection interval on it.  Use deadline mointoring to create the lot one day in advance of expiration.
    One more option:  Use standard calibration inspection to set up a calibration program.. I.e. recalibate every 15 days.
    Craig
    Edited by: Craig Snyder on Mar 25, 2008 1:08 PM

  • Light Switch 2011 "C#" How to allow filter which take more than one entry to take * and show all other entries?

    Dear All,
    I have created the following code which extended my filter functionality and allowed a to take more than one entry (Comma have to be inserted after
    each entry). 
    For example:
    "Country Filter" can take ----> Germany,Egypt,Holand<o:p></o:p>
    "City Filter " can take ---------> Berlin,Münster
    if (Country_PAR != null)
    String[] Country_Array = Country_PAR.Split(new Char[] { ','});
    query = from p in query where Country_Array.Contains(p.Hotel_Country) select p;
    if (City_PAR != null)
    String[] City_Array = City_PAR.Split(new Char[] {','});
    query = from p in query where City_Array.Contains(p.Hotel_City) select p;
    Now want to extend it more and say something like:
    If  * is included ---- > Give me all entries        
         ex. Ge*     This will give me everything which starts with Ge
    If <> is entred -----> Give me entries which are not equal to a certain entry
         ex. Country Filter = <> Germany          give me all other entries except Germany
    Thanks alot,
    Zayed

    Thanks your reply. I mean no one know my feeling. except if the new car is your. If Geek Squad can't install it. Just let me know and go. right? I ask many time? Are you ok to finish? He said yes. First time fail after 5 hours long wait and tow my car to Toyota repair. Second time said only take 20 to 30 minutes to program the key. but fail again after about 4 hours 30 minutes long wait and head light is not automatic turn on at night. I have to take a day off drive to Toyota repair. My time is money. wait there more than 10 hours and done nothing. 5 days no car and take the subway Bus and long walk. How do I feel? I m the customer. if without the customer. How you get pay? Geek Squad use my remote start and alarm and I can't return it. I loss time and money. My new car has a repair record. That is what Bestbuy want to do for the customer. Geek Squad work for Bestbuy. right? You are not just loss one customer. You will loss more and more than the remote start alarm cost. Bestbuy will not know? How come just 200$ remote start alarm and the 50$ module. Bestbuy don't want to reimburse. I m not tell you to pay me 5 days for rental car. why don't just want a happy ending? Bestbuy is big company. I m very small. 250$ it cost Bestbuy nothing. You can't let the customer loss money because you. right?

  • How to select records which are added during last week

    I have a scenerio in which I have a person dimension, which includes all the information about the person. I want to take two extracts out of it. One is monthly and one is on weekly basis. In the monthly I am just taking data for that particular month and then joining it with the Fact table. It is simple and I have already done it. I am having trouble for doing it on weekly basis of the current month, what I want to do is after the 1st week I want to select the new persons which were added (delta) during the 1st week. In the end of 2nd week I want to select those records which were added during 2nd week and so on for all the 4 weeks. e.g.
    Day
    8     The person’s which were added during 1st – 7th
    15     The person’s which were added during 8th – 14th
    23     The person’s which were added during 15th – 22nd
    31     The person’s which were added during 23rd – 31st
    Any suggestions will be appriciated please. Thanks

    A few steps arem required
    1) when inserting or updating a record in the target table set wk and mth IND to 'N'
    2) when running the week load after loading the data in the proper target end table
    set the wk ind to 'N' where wk_ind = 'Y'
    3) when running the month load after loading the data in the proper target end table
    set the wk ind to 'N' where mth ind = 'Y'
    did this help ?
    DJ

  • How to select rows which starts with

    In the below example I want only the rows which starts with the word CERTIFICATE.
    How do we do?
    create table full_text(text clob);
    insert all
    into full_text values('CERTIFICATE OF SERVICE')
    into full_text values('APPLICATION FOR CERTIFICATE')
    into full_text values('CERTIFICATE OF LIABILITY')
    into full_text values('CERTIFICATE OF TITLE')
    SELECT * FROM DUAL ;
    COMMIT;
    CREATE INDEX CTX_INDX_TEXT ON full_text (TEXT) INDEXTYPE IS CTXSYS.CONTEXT;
    SQL> select * from full_text where contains(text,'$CERTIFICATE')>0 ;
    TEXT
    CERTIFICATE OF TITLE
    CERTIFICATE OF LIABILITY
    APPLICATION FOR CERTIFICATE
    CERTIFICATE OF SERVICE
    The 3rd row show not appear.
    Thanks

    I understand what Roger is saying. Since it is past his bedtime there in the UK and still sunny here in California, here is an example for you:
    SCOTT@orcl_11g> create table full_text(text clob)
      2  /
    Table created.
    SCOTT@orcl_11g> insert all
      2  into full_text values('CERTIFICATE OF SERVICE')
      3  into full_text values('APPLICATION FOR CERTIFICATE')
      4  into full_text values('CERTIFICATE OF LIABILITY')
      5  into full_text values('CERTIFICATE OF TITLE')
      6  SELECT * FROM DUAL
      7  /
    4 rows created.
    SCOTT@orcl_11g> CREATE OR REPLACE PROCEDURE your_proc
      2    (p_rowid IN           ROWID,
      3       p_clob     IN OUT NOCOPY CLOB)
      4  AS
      5  BEGIN
      6    FOR r IN
      7        (SELECT text
      8         FROM      full_text
      9         WHERE  ROWID = p_rowid)
    10    LOOP
    11        DBMS_LOB.WRITEAPPEND (p_clob, 8, 'XXSTART ');
    12        DBMS_LOB.APPEND (p_clob, r.text);
    13        DBMS_LOB.WRITEAPPEND (p_clob, 6, ' XXEND');
    14    END LOOP;
    15  END your_proc;
    16  /
    Procedure created.
    SCOTT@orcl_11g> SHOW ERRORS
    No errors.
    SCOTT@orcl_11g> BEGIN
      2    CTX_DDL.CREATE_PREFERENCE ('your_datastore', 'USER_DATASTORE');
      3    CTX_DDL.SET_ATTRIBUTE ('your_datastore', 'PROCEDURE', 'your_proc');
      4    CTX_DDL.SET_ATTRIBUTE ('your_datastore', 'OUTPUT_TYPE', 'CLOB');
      5  END;
      6  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl_11g> CREATE INDEX CTX_INDX_TEXT ON full_text (TEXT) INDEXTYPE IS CTXSYS.CONTEXT
      2  PARAMETERS ('DATASTORE your_datastore')
      3  /
    Index created.
    SCOTT@orcl_11g> select * from full_text where contains(text,'XXSTART $CERTIFICATE')>0
      2  /
    TEXT
    CERTIFICATE OF SERVICE
    CERTIFICATE OF LIABILITY
    CERTIFICATE OF TITLE
    SCOTT@orcl_11g>

  • How to select 1st and 15th of every month

    hello,
    what is the select statement to get 1st and 15th of every month from todays date till the end of current fiscal year (sep 30th)
    ex:
    June 15th - 06/15/2008
    July 1st - 07/01/2008
    July 15th - 07/15/2008
    sep 1st - 09/01/2008
    sep 15th - 09/15/2008

    SELECT
         TO_CHAR(The_Date, 'FMMonth DdTH')
          || ' - ' || TO_CHAR(The_Date, 'MM/DD/YYYY')
    FROM
          WITH
              Months
          AS
              (SELECT Level M FROM Dual CONNECT BY Level <= 9)
          SELECT
              TO_DATE(M, 'MM')     The_Date
          FROM
              Months
          UNION ALL
          SELECT
              TO_DATE(M, 'MM') + 14     The_Date
          FROM
              Months
    WHERE
         The_Date > SysDate
    ORDER BY
         The_Date

  • How to select on which server to run the restore job?

    Hello gurus!
    We run OSB 10.4.0.2.0 (Solaris)
    There are several media-servers in configuration one of them is temporaroly unavailable.
    When I issue a restore job on the admin server it tries to be execured on that media server which is unavailable, see the output of lsjob -l:
    admin/3:
    Type: restore 1 item
    Restore to host: istore
    Media file number: 198
    Volume: OSB-CATALOG-MF-000014
    Restore original path:
    To path: /tmp/111
    Scheduled time: none
    State: retryable at 2012/12/12.13:18 ("lsjob --log admin/3" for details)
    Priority: 100
    Privileged op: no
    Run on host: mxdb-fin-2
    Attempts: 0
    I was unable to find any option which may tell OSB to run on istore server. Could you suggest any?

    You could simply take the media server out of service which means OSB won't try to use it. When it is available again, you can put it back in service.
    Or, you could restrict the backup to specific media server and tape drives.
    Donna

  • Anyone ever see 5Gb of data usage take place in one day?

    I have never used more than 2Gb in an entire month, then suddenly yesterday I get a text message from Verizon that I used almost 5Gb - in one morning!  I wasn't even using my iPhone for anything unusual, and most of the day I was in my office connected to wifi with the phone in my purse. Thoughts?
    Nothing in my settings yesterday was any different than any other day. I use iCloud backup, but only on wifi. There were apps running in the background, but that is always the case. I don't stream music, movies, or games. 5Gb is a lot!
    I should add - I did pre-order an iPhone 6 yesterday morning. Can't help but think that could have something to do with this...

    mrhelper, we appreciate the fact that you are (apparently) a volunteer here trying to assist people , and probably not a paid vzw employee (thank you for that) . Secondly, no one asked for your opinion on the validity of people's claims, even though JUST LIKE US, you are free to offer BOTH you interpretation of comments, and any facts you have related to your own experience. However it might be concluded that by creating 'static' in these forums, there may be people out there who would feel that claims and statements made from a standpoint of frustration and dissapointment regarding how vzw conducts business with us,that these statements  are not valid simply because YOU (or any other person) does not share our position and has not been treated in the same manner as we have. There is room for all viewpoints to be shared here, but don't attempt to invalidate someone's experience by commenting that you have not been treated the same way. Thank you again, but some of us expect verizon itself to address issues with us directly and in some cases the experiences shared here between consumers can be enlightening and may lead to alternate courses of action the would reslove issues that we are unable to get this company to resolve voluntarily.

  • How to Check files which is older than 14 days in particuler folder using IF condition in Batch script

    Hi,
    I have to check the zip files created before 14 days by using Batch script.
    Any conditional statement needed ?
    Thanks,
    Jitu

    But this script is failing if the files are not present in the same folder.
    So I am thinking to loop the statement to check if files are not there exit from the loop.
    The script does not fail - it reports that no files are found. You can detect this like so:
    if %ErrorLevel% NEQ 0 echo "There are no zip files!"
    There is no loop in your script that you can exit from.

  • How to select the first record?

    Hi,
    Could anyone tell me how to select the first record of every
    group?
    ex, I want to find out every customer their first purcaseDate.
    CustomerID PurcaseDate Region
    A00000001 2001/01/01 AA
    A00000001 2001/02/02 AA
    A00000002 2001/03/01 AC
    A00000002 2001/05/07 AC
    A00000003 2001/03/05 DD
    result:
    A00000001 2001/01/01 AA
    A00000002 2001/03/01 AC
    A00000003 2001/03/05 DD
    Thanks

    Vincent,
    You could do it as Carl suggested, with a couple of
    corrections.  You would need to include the CustomNo column in
    the order by clause of your cursor.  You would also need to add
    a where clause to your update statement, otherwise everywhere
    Region in the table would be updated with the same value of the
    last CustomNo in the cursor, regardless of the CustomNo in the
    table.  See corrected code below:
    DECLARE
      CURSOR     cust
      IS
      SELECT     DISTINCT CustomNo, Region, Purchase_Date
      FROM       my_table
      ORDER BY   CustomNo, Purchase_Date, Region;
      c_customer VARCHAR2 (9) := '...';
      c_region   VARCHAR2 (2) := '..';
      cntr       NUMBER := 0;
    BEGIN
      FOR x IN cust
      LOOP
        IF x.CustomNo != c_customer
        THEN
          c_customer := x.CustomNo;
          c_region := x.Region;
        ELSE
          UPDATE my_table
          SET    Region = c_region
          WHERE  CustomNo = c_customer;
          cntr := cntr + 1;
          IF cntr = 25
          THEN
            COMMIT;
            cntr := 0;
          END IF;
        END IF;
      END LOOP;
      COMMIT;
    EXCEPTION
      WHEN OTHERS THEN 
        NULL;
    END;
    Another option is that you could just use one update statement,
    like this:
    UPDATE my_table a
    SET    Region =
           (SELECT DISTINCT Region
            FROM   my_table b
            WHERE  (CustomNo, Purchase_Date) IN
                   (SELECT   CustomNo, MIN (Purchase_Date)
                    FROM     my_table
                    GROUP BY CustomNo)
            AND    a.CustomNo = b.CustomNo)
    Barbara

  • When there are several tabs open, why does the search always take place on the 2nd tab (the first tab seems never to change from the home page) despite my selecting a different tab in which to do a google search?

    I have Mozilla Firefox 10.0. When I open it, it correctly opens on the homepage in the first tab. Once I have another, or several, tabs open, no matter which tab is active, any google search I do immediately takes place in tab No 2. It doesn't seem to matter how many times I go to e.g. tab 4 to do a search (because I wish to compare with the webpage open in tab 2), yet it always now does the search in tab 2. This is very irritating. There must be some setting that has gone pear-shaped, but where/which? Any suggestions? Thanks.

    Try the Firefox SafeMode to see how it works there. <br />
    ''A troubleshooting mode, which disables most Add-ons.'' <br />
    ''(If you're not using it, switch to the Default Theme.)''
    * You can open the Firefox 4.0+ SafeMode by holding the '''Shft''' key when you use the Firefox desktop or Start menu shortcut.
    * Or use the Help menu item, click on '''Restart with Add-ons Disabled...''' while Firefox is running. <br />
    ''Don't select anything right now, just use "Continue in SafeMode."''
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before using the Firefox shortcut (without the Shft key) to open it again.''
    '''''If it is good in the Firefox SafeMode''''', your problem is probably caused by an extension, and you need to figure out which one. <br />
    http://support.mozilla.com/en-US/kb/troubleshooting+extensions+and+themes
    ''When you figure out what is causing that, please let us know. It might help other user's who have that problem.''

  • How do I create my own favorite template for DVD slideshows? I used to be able to select this from pulldown menu, but cannot now do so. I am directed straight to templates, which take more memory. I have a large slideshow, and need all the space I can get

    First, how do I create my own favorite theme template for DVD slideshows? I used to be able to select this from pulldown menu, but cannot now do so. I am directed straight to already existing themes, which take more memory. I have a large slideshow, and need all the space I can get. I just want to use a picture as my DVD cover, and then insert a slideshow. Also, when I try to burn my 8.5gb double sided slideshow, all that burns is the music. It is a large slideshow, a memorial on the life of my now deceased brother. This means a lot to me and to my family, and I am having so much trouble trying to burn it. I have gone into Project View and selected appropriately. The bar shows I have room to burn this DVD, but it does not burn.  I have burned so many DVDs in the past, but this one just will not burn. I am so confused at this point. I will say this is the first 8.5gb I have attempted to create and burn. My specs list a 7.7gb or 4.7gb as operable....but there are no 7.7gb dvds. I had to purchase 8.5gb. Help? What am I doing wrong? I have spent so much time on this, and just cannot figure it out.

    Final Cut is a separate, higher end video editor.  The pro version of iMovie.
    Give iPhoto a look at for creating the slideshow.  It's easy to assemble the photos in an album in iPhoto, put them in the order you want and then make a slideshow of them.  You can select from various themes and transitions between slides and add music from your iTunes library.
    When you have the slidshow as you want use the Export button at the bottom of the iPhoto window and export with Size = Medium or Large.
    Save the resulting Quicktime movie file in your Movies folder.
    Next, open iDVD, choose your theme and drag the QT movie file into the menu window being careful to avoid any drop zones.
    Then follow this workflow to help assure the best qualty video DVD:
    Once you have the project as you want it save it as a disk image via the File ➙ Save as Disk Image  menu option. This will separate the encoding process from the burn process. 
    To check the encoding mount the disk image, launch DVD Player and play it.  If it plays OK with DVD Player the encoding is good.
    Then burn to disk with Disk Utility or Toast at the slowest speed available (2x-4x) to assure the best burn quality.  Always use top quality media:  Verbatim, Maxell or Taiyo Yuden DVD-R are the most recommended in these forums.
    The reason I suggest iPhoto is that I find it much easier to use than iMovie (except for the older iMovie 6 HD version).  Personal preferences showing here.

  • I have a new mac book air and every time i start up the computer it loads all my emails, somewhere around 10,000.  Even though I delete them, which take a long time, they keep coming back?  How do I delete all my old emails?  thank you

    I have a problem with my Macbook air which keeps reloading all my old emails to my inbox.  Even thought i delete them, which takes a long time, over 10,000...they keep coming back?  How do I delete old messages?  Thank you

    check your account settings, possibly under advanced settings.
    look for an option to check "remove messages from server" or similar.

Maybe you are looking for

  • Replaced battery and.....

    I have a 3rd gen iPod and over the last little while it had stopped being able to have more than about 5 minutes of charge. So I decided to order a replacement kit and replace the battery. So I open it up, replace the battery, and when I close it bac

  • CJE0 - REMOVE A VARIABLE FROM TAB 'VARIABLES'

    Hi , I'm modifying a custom report creat by third party . I'm not able to remove the variable Object currency (it's shown in the selection screen of the report) as I don't see any button which lets me change(also in change mode) , the variables prese

  • Session problem on clustered sun fire with SP6.1

    Hi All, I am having a problem with a webapplication on a clustered system. In the following I describe the current system setup. I will then describe the setup of the web application. Following this, I explain the trouble I'm having with sharing sess

  • Lightroom 3+ (Mac OSX) Spinning Beach Ball on Import only?

    Hello --   When I first starting using Lightroom 3 on my 27" quad-core iMac, detection of an inserted memory card (Compact Flash or SDHC) was instantaneous.  It's one of the things that really attracted me to Lightroom -- plug in, and go!   Sometime

  • Can I choose the keyboard in an American Apple Store?

    Hello, if I buy a Macbook air in the online apple store I can choose between American and Spanish Keyboard. Can I request an Italian Keyboard in an American Apple Store? Thanks.