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

Weird response with From/To Date Search

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

    Weird response with From/To Date Search

    I'm trying to print a series of records based on a field called "date_written."

    I have a dialog set up with "FromDate" and "ToDate controls." The problem is that if I enter the exact same date in both fields, I get the correct number of records returned with that particular date.

    But if I enter a span of dates, (06/03/2006 - 06/05/2006 for example), I get a return of records that all fall within the correct month and day, but in ANY year, as opposed to just 2006.

    Here's my expression:

    HTML Code:
    dim cFilter as c
    cFilter = "between(dtoc(date_written)," + s_quote(FromDate) + "," + s_quote(ToDate) + ")"
    filename = session.session_folder + chr(92) + "foo.pdf"
    report.saveas("fieldlisting@[PathAlias.ADB_Path]\violations.dbf", "pdf", cfilter,"", filename, .f.)
    if file.exists(filename)
        response.redirect(session.session_url + "foo.pdf?" + time("hms3"))
    end if
    Anyone have an idea why I'm getting these weird results?
    Sergeant Richard Hartnett
    Hyattsville City Police Department
    Maryland

    #2
    Re: Weird response with From/To Date Search

    Steve Wood any ideas on this one?
    Sergeant Richard Hartnett
    Hyattsville City Police Department
    Maryland

    Comment


      #3
      Re: Weird response with From/To Date Search

      Try:

      Code:
      cFilter = "between(date_written," + s_quote(FromDate) + "," + s_quote(ToDate) + ")"
      It seems to me that your original expression:
      Code:
      cFilter = "between([COLOR="Red"]dtoc[/COLOR](date_written)," + s_quote(FromDate) + "," + s_quote(ToDate) + ")"
      tries to determine if the character string equivalent of your date_written field value is "between" two dates. If I'm reading this correctly that won't work because character strings are not date values. The Between() function requires that all 3 parameters passed to it be of the same data type. I think maybe you're mixing character and date data types.

      -- tom

      Comment


        #4
        Re: Weird response with From/To Date Search

        Thanks for the reply Tom.

        Unfortunately it did not make a difference, I'm still getting years other than the one called for in the dates entered, even with the addition of "(dtoc".

        Would you have a suggestion as to a better expression to use in this scenario?
        Sergeant Richard Hartnett
        Hyattsville City Police Department
        Maryland

        Comment


          #5
          Re: Weird response with From/To Date Search

          One of the best ways to test any expression is to use the interactive window in the code editor. If you assign character values to FromDate and ToDate and put your expression in the interactive, this is what you get

          Code:
          FromDate = "01/12/2002"
          ToDate = "01/15/2002"
          
          cFilter = "between(date_written," + s_quote(FromDate) + "," + s_quote(ToDate) + ")"
          
          ?cFilter
          = between(date_written,"01/12/2002","01/15/2002")
          As Tom points out, this is trying to compare 2 character values when you want to compare 2 dates. Assuming that date_written is a date value (you didn't specify), you can open the table in the desktop using the default browse and use the query genie to build a basic expression for between 2 dates. This is what you would get using the invoice_header table in Alpha Sports
          Code:
          between(Date,ctod("01/12/2002"),ctod("01/15/2002"))
          To put this in another expression for cFilter, you would get
          Code:
          cFilter = "between(Date,ctod(\"01/12/2002\"),ctod(\"01/15/2002\"))"
          Converting this to use variables, you would get
          Code:
          FromDate = "01/12/2002"
          ToDate = "01/15/2002"
          
          cFilter = "between(Date,ctod(\""+FromDate+"\"),ctod(\""+ToDate+"\"))"
          If you try this in the interactive window, you will find that the last expression gives the same results as the expression built by the query genie. Now, if date_written is character, convert it to a date using ctod() and you would get
          Code:
          cFilter = "between(ctod(character_Date),ctod(\""+FromDate+"\"),ctod(\""+ToDate+"\"))"

          Comment


            #6
            Re: Weird response with From/To Date Search

            ????

            addition of "(dtoc"

            ????

            I was recommending that it be deleted... since it's already present in the expression you posted.

            Try:

            Code:
            cFilter = "between(date_written, s_quote(FromDate) , s_quote(ToDate))"
            -- tom

            Comment


              #7
              Re: Weird response with From/To Date Search

              Yeah sorry Tom, that's what happens when you work on this stuff on the midnight shift!

              Originally I had tried both ways. (With "dtoc" and without) By the time I had posted the message, my test expression did have it included, but when I went to the actual dialog component, it was missing, so for some strange reason I though you were telling me to put it in, when you were actually telling me to take it out.

              In any event, it didn't work either way. Having it in gave me too many returns, and leaving it out gave me none.

              However, using the following expression posted by Ed worked just fine:

              HTML Code:
              cFilter = "between(Date_written,ctod(\""+FromDate+"\"),ctod(\""+ToDate+"\"))"
              As my "Date_written" field is actually a DATE field type.

              Many thanks for both of you.
              Sergeant Richard Hartnett
              Hyattsville City Police Department
              Maryland

              Comment


                #8
                Additional Help Needed .. (With To/From Date Search)

                Okay now that I've got the To/From working fine, I need to add two additional filters. "Code" and "Resolved." It works fine with one additional filter, but not with two. What's wrong with my fourth filter?

                It works fine with these three filters:
                HTML Code:
                cFilter = "between(Date_written,ctod(\""+FromDate+"\"),ctod(\""+ToDate+"\"))" ".and. code = " + s_quote(code)
                When I add in this fourth filter nothing happens:
                HTML Code:
                cFilter = "between(Date_written,ctod(\""+FromDate+"\"),ctod(\""+ToDate+"\"))" ".and. code = " + s_quote(code) .and. resolved = " + s_quote(resolved)"
                I know it's just a matter of syntax, but I haven't been able to figure it out.
                Sergeant Richard Hartnett
                Hyattsville City Police Department
                Maryland

                Comment


                  #9
                  Re: Weird response with From/To Date Search

                  Start by removing the final ".

                  Given your experience and others' with filter problems, I wish I had time to write an article about this, but I'll stop now at the suggestion:

                  You can try everything out in the regular control panel code tab to figure stuff like this out. Put a filter together, then show it, for instance, with A5_Show_Variable() to see what's really coming together.
                  -Steve
                  sigpic

                  Comment


                    #10
                    Re: Weird response with From/To Date Search

                    Yeah I do seem to battle with it.

                    I actually tried using the code editor, and WITH the double quotes at the end, the editor tells me that there are extra characters at the end.

                    Removing the quotes gives me a message that the syntax is correct, but nothing happens.

                    (Maybe you should write an article about it. We could all use the help!)
                    Sergeant Richard Hartnett
                    Hyattsville City Police Department
                    Maryland

                    Comment


                      #11
                      Re: Weird response with From/To Date Search

                      Two useful resources:

                      There's a very good article at www.learn alpha.com

                      http://www.learn alpha.com/QuerySyntax/QuerySyntax.htm


                      The Alpha Five help file discussion of the Tablecount() function contains a fairly complete set of examples illustrating how to construct filter expressions that would be passed as an argument to the function.

                      -- tom

                      Comment

                      Working...
                      X