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

Date Total on Report

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

    Date Total on Report

    Ok, I'm trying to do a calculation that tells me the number of days between a date range. For example:

    The report is has these dates, 01/01/2005, 02/05/2005, 01/01/2005 02/06/2005 = 3 days (yes I know I repeated a date, but I need that filtered out).

    Here is the expression I am looking at. I pulled it out of the alpha help file, but it keeps telling me that it is an invalid expression. I have adjusted it to what I need.

    Days=TABLECOUNT("cdr.DBF","Between(offhookdate, "(Cdr-"Offhookdate"= Var-"begindate ) .and. (Cdr-"Offhookdate"=Var-"enddate )")

    The variables begindate and enddate are both set as global variables (as D) and they are set from the filter.

    Am I trying to get this to do too much here, since the records are based off a filtered set? This is driving me nuts a little here.

    Thanks!
    Steve Hall
    Steve Hall

    #2
    RE: Date Total on Report

    "trying to do a calculation that tells me the number of days" - tablecount() returns a number of records satisfying a filter, no more, no less.

    Paste

    TABLECOUNT("cdr.DBF","Between(offhookdate, "(Cdr-"Offhookdate"= Var-"begindate ) .and. (Cdr-"Offhookdate"=Var-"enddate )")

    into the interactive editor and you should see that, whatever this means, you have an unmatched set of quotes, rendering the expression invalid.
    There can be only one.

    Comment


      #3
      RE: Date Total on Report

      try this instead:

      TABLECOUNT("cdr.DBF","Between(offhookdate, "(Cdr-"Offhookdate"= Var-"begindate ) .and. (Cdr-"Offhookdate"=Var-"enddate )")

      tablecount("cdr","between(offhookdate,var-"begindate,var-"var-"enddate)")
      Cole Custom Programming - Terrell, Texas
      972 524 8714
      [email protected]

      ____________________
      "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

      Comment


        #4
        RE: Date Total on Report

        Well, I did that and I think I fixed the quotes. Here is what i'm getting now.

        Days = TABLECOUNT("cdr.dbf", "Between(cdr-"offhookdate{"+ dtoc(Begindate) +"}, {"+ dtoc(VarD-"EndDate) +"})")

        It is still telling me that this is an invalid calculation. When I run it through the interactive editor, it tells me "field not recognized."

        I am running this report off of a set. I know my variables are carrying across since my 2 "between" dates are showing up on my report. (In the header where I need them to). I have no idea why this is still coming up as invalid. Since the report is already being filtered when it is run, is it possible that I can use the tablecount() to just count the filtered records from the set?

        Steve Hall
        Steve Hall

        Comment


          #5
          RE: Date Total on Report

          I'm not at a machine with Alpha at present but the documentation doesn't show the table-" syntax when using tablecount(). Also I don't think "VarD-"" is proper for referring to a variable. Seems it should be "Var-"". Also the structure of between() is BETWEEN( Expression as D, Lower_Value as D, Higher_Value as D ) so I think you are missing a comma after offhookdate. You do know that you can cut and paste between the expression builder/interactive editor in Alpha and this message board?

          Try

          TABLECOUNT("cdr.dbf", "Between(offhookdate,{"+ dtoc(Var-"Begindate) +"}, {"+ dtoc(Var-"EndDate) +"})")

          but I'm working without the syntax hilighting in Alpha so this may just be closer.
          There can be only one.

          Comment


            #6
            RE: Date Total on Report

            I think this is just a variation of what Martin was suggesting. I didn't look at his response closely enough.
            There can be only one.

            Comment


              #7
              RE: Date Total on Report

              Steve:
              " I have no idea why this is still coming up as invalid"
              It is invalid for several reasons:
              First: your Between() expression is missing a comma
              Second: VarD-"EndDate should be Var-"EndDate
              Third: dtoc(Begindate) should be dtoc(var-"Begindate)

              try:
              Days = TABLECOUNT("cdr.dbf", "Between(cdr-"offhookdate,{"+ dtoc(Begindate) +"}, {"+ dtoc(Var-"EndDate) +"})")

              Or better:
              Days = TABLECOUNT("cdr.dbf", "Between_date(cdr-"offhookdate,Var-"Begindate,Var-"EndDate)")

              This will fix your expression, but will give you the wrong information: it will counts all the dates between those 2 dates, not just the unique ones. If you want only the unique dates, that's a horse of a different color.

              Gabe
              P.S. I am not sure if you should enclose "+...+" in curly parenthises ! I rarely use it.

              Comment


                #8
                RE: Date Total on Report

                Well for some reason I still can't get it to work. It loads and says it's a valid function, but how about this.
                Just to make it easier, I have a begindate and enddate that I just need a day total on. The dates are entered as a query from a form.

                Ex: 01/01/2000 (begindate global var) and 01/02/2000 (enddate global variable) = 2 days

                Is there an easy way to do just this? I can then plug it into my other equation.

                Thanks
                Steve

                (The report is built off a set. I just want the range from the entered variables)
                Steve Hall

                Comment


                  #9
                  RE: Date Total on Report

                  Steve:
                  I am not clear on what you are asking:
                  First: What do you mean you can't get it to work? what do you get? Have you updated your variables? Is var-"enddate higher than var-"begindate?

                  Second: "I have a begindate and enddate that I just need a day total on"
                  I do not quite understand what you are after: do you want a "count" of the dates between the begindate & enddate? or do you want a count for all records that have any dates, begin or end?

                  In your example, you counted 2 days but one of them is a begindate and the other is an enddate? Dosn't each record have a begin and an end date? wouldn't the count in your example be 1 instead of 2? Are you trying to count the number of days Lapsed between the begin and end date for each record then total that? if that's what you want, it's quite a very simple matter.

                  I am totally confused as to what you want to achieve?
                  Gabe

                  Comment


                    #10
                    RE: Date Total on Report

                    Hey guys, you are missing the big picture!
                    What you want is the days difference between the earliest date and the latest date.
                    IOW, you need 3 calculated fields.

                    min_date = minimum(The_Date_Field)
                    max_date = maximum(The_Date_Field)
                    day_diff = calc-"Max_Date-calc-"Min_Date

                    This works if you put them in the appropriate place.

                    Comment


                      #11
                      RE: Date Total on Report

                      Melvin:
                      Maybe that's what Steve wants, or maybe what he wants (which would make more sense) is the day difference for each record then have all these diferences totaled. These are two different things.

                      I say it makes more sense since the min begindate might belong to one record(event) while the max enddate might belong to a completely diffreent event.

                      I can't surmise exactly what he wants or what is the essence of the application. It's all out of context.
                      Gabe

                      Comment


                        #12
                        RE: Date Total on Report

                        Sorry Gabe, here is what i'm looking for in essence. I just need to set up a calculated field that counts the number of days between 2 dates. I have a query setup that let's the user query all of the data between any 2 dates. The user enters the Begin Date and the End Date. The query shows all of the data between these two dates.

                        Now, what I was looking for was a formula that would allow me to average some sales totals by day. For instance, I might have queried between 01/01/04 and 01/02/04. That is a 2 day period. I need to find a command that would allow me to display "2" in a field on my report. Or if I query from 01/01/04 and 01/01/05 I need it to display a "366".

                        This ultimately would allow me to average out my sales totals by day with the average command. That is what I am looking for and I am at a loss as to how to do this.

                        Thanks!
                        Steve Hall
                        Steve Hall

                        Comment


                          #13
                          RE: Date Total on Report

                          Steve,

                          as previous indicated:

                          day_diff = End_date - Begin_Date

                          Average Sales would then be

                          Total_Sales / day_diff.

                          Not sure how you are getting total sales.
                          Perhaps
                          Total_Sales = TABLESUM( Lookup_Table as C, Filter as C, Lookup_Expression as C )

                          Comment


                            #14
                            RE: Date Total on Report

                            Steve:
                            As I anticipated, you are going to fix the expression but get the wrong information:
                            If two records have the same date: say 01/01/2005 and three records have 01/02/2005, tablecount() will give you a count of 5 when in reality there were only 2 dates.

                            The easiest way to do that would be as Melvin suggested with one modification, the formula should be:
                            "b"endate-begindate+1 "/b"since you have to include begindate.

                            That gives you the correct number of days to use in your averages.

                            Gabe

                            Comment


                              #15
                              RE: Date Total on Report

                              Steve:
                              As I anticipated, you are going to fix the expression but get the wrong information:
                              If two records have the same date: say 01/01/2005 and three records have 01/02/2005, tablecount() will give you a count of 5 when in reality there were only 2 dates.

                              The easiest way to do that would be as Melvin suggested with one modification, the formula should be:
                              endate-begindate+1 since you have to include begindate.

                              That gives you the correct number of days to use in your averages.

                              Gabe

                              Comment

                              Working...
                              X