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

Last Day Of The Month Code

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

    Last Day Of The Month Code

    I have written the following expression for anyone who neeeds to find the last day of a month:

    IF(LEN(ALLTRIM(RIGHT(DTOC(CTOD(ALLTRIM(STR(MONTH(EDATE),2,0))+"/31/"+ALLTRIM(RIGHT(STR(YEAR(EDATE),4,0),2)))),2)))>0,CTOD(ALLTRIM(STR(MONTH(EDATE),2,0))+"/31/"+ALLTRIM(RIGHT(STR(YEAR(EDATE),4,0),2))),IF(LEN(ALLTRIM(RIGHT(DTOC(CTOD(ALLTRIM(STR(MONTH(EDATE),2,0))+"/30/"+ALLTRIM(RIGHT(STR(YEAR(EDATE),4,0),2)))),2)))>0,CTOD(ALLTRIM(STR(MONTH(EDATE),2,0))+"/30/"+ALLTRIM(RIGHT(STR(YEAR(EDATE),4,0),2))),IF(LEN(ALLTRIM(RIGHT(DTOC(CTOD(ALLTRIM(STR(MONTH(EDATE),2,0))+"/29/"+ALLTRIM(RIGHT(STR(YEAR(EDATE),4,0),2)))),2)))>0,CTOD(ALLTRIM(STR(MONTH(EDATE),2,0))+"/29/"+ALLTRIM(RIGHT(STR(YEAR(EDATE),4,0),2))),CTOD(ALLTRIM(STR(MONTH(EDATE),2,0))+"/28/"+ALLTRIM(RIGHT(STR(YEAR(EDATE),4,0),2))))))

    Substitute EDATE (a date filed value) with your date, and you get the end of the month date.

    If anyone knows of a more efficient way or function in A5 let me know.

    #2
    RE: Last Day Of The Month Code

    i would do something like this

    addmonths(ctod(ut(str(month(edate)))+chr(92)+"01"+chr(92)+ut(str(year(edate)))),1)-1

    Comment


      #3
      RE: Last Day Of The Month Code

      I don't know if this is "more efficient", but here is the method that I use:

      m=month(date())

      if m=1
      mstr="31"
      end if

      if m=2
      if year(date())=2000 .or. year(date())=2004 .or. year(date())=2008 .or. year(date())=2012
      mstr="29"
      else
      mstr="28"
      end if
      end if


      if m=3
      mstr="31"
      end if

      if m=4
      mstr="30"
      end if

      if m=5
      mstr="31"
      end if

      if m=6
      mstr="30"
      end if

      if m=7
      mstr="31"
      end if

      if m=8
      mstr="31"
      end if

      if m=9
      mstr="30"
      end if

      if m=10
      mstr="31"
      end if

      if m=11
      mstr="30"
      end if

      if m=12
      mstr="31"
      end if

      mstr="-"+mstr+"-"

      date2=ctod(alltrim(str(month(date()))+mstr+alltrim(str(year(date())))))

      Gary Traub
      Gary S. Traub, Ph.D.

      Comment


        #4
        RE: Last Day Of The Month Code

        Robert, Michael & Gary,

        There are a couple of problems with all your approaches
        1. CTOD() converts differently depending upon American or European date formats
        2. You have not accounted for the blank date case


        function MonthEnd as D(DateVal as D)

        ' Returns date of Last day of DateVal's month or blank

        MonthEnd=iif(DateVal={},{},Addmonths(DateVal-Day(DateVal)+1,1)-1)

        end function


        Hope this helps!

        Regards,

        Ira J. Perlow
        Computer Systems Design & Associates
        [email protected]
        Regards,

        Ira J. Perlow
        Computer Systems Design


        CSDA A5 Products
        New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
        CSDA Barcode Functions

        CSDA Code Utility
        CSDA Screen Capture


        Comment


          #5
          RE: Last Day Of The Month Code

          I don't ever use European settings, but I appreciate your suggestion, and will try it tomorrow.

          How do I implement the function in the table, or browse?

          I've tried the action script in the field rules, but it hasn't worked for me (I may be doing something wrong).

          Comment


            #6
            RE: Last Day Of The Month Code

            Robert,

            I believe you have to create a global function. Then in field rules, forms, reports, etc. MonthEnd({06/01/2000})

            Daryl

            Comment


              #7
              RE: Last Day Of The Month Code

              Michael:

              Your script is ingenius! Works beautifully. Thanks ...

              Gary
              Gary S. Traub, Ph.D.

              Comment


                #8
                RE: Last Day Of The Month Code

                Ira:

                Actually, your function is the one I was talking about. Very consice, and efficient. Thanks!
                Gary S. Traub, Ph.D.

                Comment


                  #9
                  RE: Last Day Of The Month Code

                  Ira,
                  Thanks for a great expression! I use a similar approach, but yours accounts for any date format. The simplest approach is always the best.

                  Jerry

                  Comment


                    #10
                    RE: Last Day Of The Month Code

                    Thanks a lot.

                    The function works fine (I used a prior thread to figure out how to incorporate the function), but the halt script message appears each time I re-evaluate the field rules.

                    Is that normal?

                    If so, how do I prevent it?

                    Comment


                      #11
                      RE: Last Day Of The Month Code

                      Robert,

                      Anytime a script runs, A5HALT will pop up if the A5HALT.DLL file is present. This allows you to abort script execution if the script hangs. I presented the solution as global script function, but in the field rules you'd be better served just to use the expression with the appropriate Date field substituted for the DateVal field, as in

                      iif(DateField={},{},Addmonths(DateDield-Day(DateField)+1,1)-1)

                      The point is that if the expression is all in one (as opposed to multiple lines of script code, you can just use the expression.

                      Just because I presented the expression in a global function, doesn't mean you can't use just the expression. You may be unfamiliar with A5, but try to extrapolate from what's presented. You will seldom ever see the code exactly as you need it.

                      Regards,

                      Ira J. Perlow
                      Computer Systems Design & Associates
                      [email protected]
                      Regards,

                      Ira J. Perlow
                      Computer Systems Design


                      CSDA A5 Products
                      New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
                      CSDA Barcode Functions

                      CSDA Code Utility
                      CSDA Screen Capture


                      Comment


                        #12
                        RE: Last Day Of The Month Code

                        Ira:

                        I don't write too many scripts, but I am curious about the one you wrote here. I copied it into my A5V1.2 and compiled it.... that went ok.

                        But I wanted to see the value so I tried to use ui_msg_box(,,) but then it wouldn't compile.

                        First I tried to display it with: ui_msg_box("date is",dtoc(MonthEnd), when that didn't work, I tried the following (which also wouldn't work)

                        test=CTOD(MonthEnd)
                        ui_msg_box("date is",test)

                        They both compiled, but both returned the following error message "invalid variable type"

                        I attached the little script to a button (push).

                        Any ideas how I can get this to display?

                        Thanks in advance.

                        Cheers

                        Comment


                          #13
                          RE: Last Day Of The Month Code

                          Derek,

                          The way I made the MonthEnd function is that you must give it a date value (of date type) and it returns the end of the month for the date value as another date value. Thus to get the end of the current month, you would use the system date, which is returned by the built-in function DATE(). If you want to convert it to a character type (for display in ui_msg_box etc), you must use DTOC() function. Thus the expression would look like

                          ui_msg_box("date is",dtoc(MonthEnd(Date())))

                          Of course you could use a date type field or any valid date expression substituted for DATE().

                          Regards,

                          Ira J. Perlow
                          Computer Systems Design & Associates
                          [email protected]
                          Regards,

                          Ira J. Perlow
                          Computer Systems Design


                          CSDA A5 Products
                          New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
                          CSDA Barcode Functions

                          CSDA Code Utility
                          CSDA Screen Capture


                          Comment


                            #14
                            RE: Last Day Of The Month Code

                            Derek:

                            To your little script, you need to add the following:

                            dim test as d

                            so that the variable "test" is recognized as a date variable.

                            Also, in your first script, you are missing one parenthesis at the very end, i.e., try:

                            ui_msg_box("date is",dtoc(MonthEnd))

                            Hope this helps ...

                            Gary
                            Gary S. Traub, Ph.D.

                            Comment

                            Working...
                            X