Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Dates within dates

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dates within dates

    Hi all, I'm stuck and would appreciate a pointer in the right direction.

    The table I am working with has multiple events recorded for each person.
    The records contain a start date and an end date.
    If the start date or end date in any record overlaps any other dates I need to identify those records and get them repaired as overlaps are not allowed.
    Crude example attached.
    Attached Files
    See our Hybrid Option here;
    https://hybridapps.example-software.com/


    There are 3 things you can do in any situation;
    Live with it, Change it or Walk away from it.

  • #2
    Re: Dates within dates

    Does the id field have any bearing on the issue? IOW, do you want to find overlaps based on the id and the dates? Or do you want to see any and all overlaps?
    There can be only one.

    Comment


    • #3
      Re: Dates within dates

      ID and dates Stan.
      There are about 1.5 million record spread across about 350k ID's.
      Each ID has it's own set of dates, and I need to check for date overlaps WITHIN ID.
      See our Hybrid Option here;
      https://hybridapps.example-software.com/


      There are 3 things you can do in any situation;
      Live with it, Change it or Walk away from it.

      Comment


      • #4
        Re: Dates within dates

        Not rigorously tested so stick a debug(1) at the top so you can halt if need be. Did test with two id's and date ranges. No clue as to how fast it will be.

        Code:
        ids = table.external_record_content_get("sample table","alltrim(id)","id",".t. .and. unique_key_value()")
        for each fum in ids
        	rangd = table.external_record_content_get("sample table","cdate(startdate)+'|'+cdate(enddate)","cdate(startdate)","id = "+quote(fum.value))
        	tbl = table.open("sample table")
        	ix = tbl.query_create("N","id = "+quote(fum.value),"cdate(startdate)")
        	tbl.fetch_first()
        	while .not. tbl.fetch_eof() 
        		this_one = cdate(tbl.startdate)+"|"+cdate(tbl.enddate)
        		test_range = word_subtract(rangd,this_one,crlf())
        		for each foo in test_range
        			if between(cdate(tbl.startdate),word(foo.value,1,"|"),word(foo.value,2,"|"))
        				tbl.change_begin()
        				tbl.overlapflag = .T.
        				tbl.comment = "Conflicts"
        				tbl.change_end(.T.)
        			end if
        		next
        		tbl.fetch_next()
        	end while
        	ix.drop()
        next
        tbl.close()
        There can be only one.

        Comment


        • #5
          Re: Dates within dates

          Thanks Stan, I'll give it a whirl tomorrow now as it late here.
          Really appreciate your help.
          T
          See our Hybrid Option here;
          https://hybridapps.example-software.com/


          There are 3 things you can do in any situation;
          Live with it, Change it or Walk away from it.

          Comment


          • #6
            Re: Dates within dates

            Ted, define what you mean by "overlapping dates". On this side of the pond the dates in the sample date ranges do not appear to overlap, yet you have marked two as overlapping. Color me confused? -- tom

            Comment


            • #7
              Re: Dates within dates

              Ted, I've made some assumptions about what an overlap might be.

              Perhaps this example will help you. It's pretty fast.

              Notice though that I've changed one of your sample records to create a 4 day overlap.

              Overview: Brute force approach. No queries run. Blast through the records. For each record blast through
              all the dates in the range from start to end.... store id's and dates and activities in an array. Sort the array by ID + date.
              March through the array. If the current ID + date matches the next you have an overlap.
              Last edited by Tom Cone Jr; 02-14-2013, 10:02 PM.

              Comment


              • #8
                Re: Dates within dates

                I haven't looked or tried yet Tom as I have some specs to get written, but I will do later.
                To answer your question in #6.
                An overlap is where more than one activity is within the same timeframe for the ID to which it relates. I used UK dd/mm/yyyy structure.
                The rules say that you cannot have two activities running at the same time, so if a date in one period is between the dates in another period that will be an overlap.

                Ted
                See our Hybrid Option here;
                https://hybridapps.example-software.com/


                There are 3 things you can do in any situation;
                Live with it, Change it or Walk away from it.

                Comment


                • #9
                  Re: Dates within dates

                  Tom, I cannot see any temp table being created.
                  Please advise if you have time.
                  See our Hybrid Option here;
                  https://hybridapps.example-software.com/


                  There are 3 things you can do in any situation;
                  Live with it, Change it or Walk away from it.

                  Comment


                  • #10
                    Re: Dates within dates

                    Left that for you.... Tom

                    Comment


                    • #11
                      Re: Dates within dates

                      Thank you.
                      See our Hybrid Option here;
                      https://hybridapps.example-software.com/


                      There are 3 things you can do in any situation;
                      Live with it, Change it or Walk away from it.

                      Comment


                      • #12
                        Re: Dates within dates

                        Have fun. If you need help let me know.

                        Comment


                        • #13
                          Re: Dates within dates

                          Ray could you clarify what you mean by over lapping? In your sample from post 1 I don't see any. Maybe you can explain the comments for records 3 and 4.

                          below is a representation as I see it. (the year is left off to make it shorter)


                          Code:
                          1 __01/01-01/02__
                          2                 __02/02-02/02__
                          3                                                            __01/04-01/05__
                          4                                       __25/03-28/03__
                          5                                                                                    __01/06-01/07
                          Tim Kiebert
                          Eagle Creek Citrus
                          A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                          Comment


                          • #14
                            Re: Dates within dates

                            Tim, its a situation for an ID, where an event occupies the same time period as another event.
                            Say that for each ID.
                            Event 1 started Monday and ran to Friday
                            Event 2 started Thursday and ran to Friday. That would create an overlap.

                            If event 1 ran mon-wed and event 2 ran thur-fri that would be no overlap.

                            Events have a start and finish date and no two event time duration may occupy the same time period.
                            Look at it as though the person doing the job can only do one thing at a time. The dates that have been entered suggest that they are doing 2 things at once.
                            If you put Stan's code into the original sample, add two activity dates say 01/01/1900 to 01/12/1900 and 01/05/1900 to 01/06/1900 you will see what happens. The period 05 to 06 is an overlap as the period 01 -12 is already populated.
                            See our Hybrid Option here;
                            https://hybridapps.example-software.com/


                            There are 3 things you can do in any situation;
                            Live with it, Change it or Walk away from it.

                            Comment


                            • #15
                              Re: Dates within dates

                              Ted, the confusion results from your original sample. There are no overlaps. Yet the records have an overlap flag set true. A couple of them have comments that suggest the presence of an overlap but there is none.

                              Comment

                              Working...
                              X