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

add_bus_days(month_start(date()),1) Ending Date Results?

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

    add_bus_days(month_start(date()),1) Ending Date Results?

    What should be the results of this combination function add_bus_days(month_start(date()),1) Using the first day of each month for the year 2006?

    Ending_Date = ADD_BUS_DAYS( Starting_Date as D, Add_Days as N [, Ignore_Holiday_Flag as C [, Holiday_Table as C ]] )

    My Diagnostics shows incrementing the Add_Days by 1 for each of the 1-20 some work days in a month works except for when the first day of the month starts on a week-end then the Ending_Date is incorrect.

    For the year 2006 I found the following; for Stating_Date being changed manually for the first day of the month (01/01/2006) or by changing the computer date for the first of each month using (month_start) both were the same results.

    (The asterisks show the incorrect months with double asterisks showing also incorrect holliday calculation )

    Starting_Date 01/01/2006 the result for Ending_Date = 01/02/2006
    Starting_Date 02/01/2006 the result for Ending_Date = 02/02/2006*
    Starting_Date 03/01/2006 the result for Ending_Date = 03/02/2006*
    Starting_Date 04/01/2006 the result for Ending_Date = 04/03/2006
    Starting_Date 05/01/2006 the result for Ending_Date = 05/02/2006*
    Starting_Date 06/01/2006 the result for Ending_Date = 06/02/2006*
    Starting_Date 07/01/2006 the result for Ending_Date = 07/03/2006
    Starting_Date 08/01/2006 the result for Ending_Date = 08/02/2006*
    Starting_Date 09/01/2006 the result for Ending_Date = 09/04/2006**
    Starting_Date 10/01/2006 the result for Ending_Date = 10/02/2006
    Starting_Date 11/01/2006 the result for Ending_Date = 11/02/2006*
    Starting_Date 12/01/2006 the result for Ending_Date = 12/04/2006*

    I maybe using this function with the wrong understanding?


    Thanks for any suggestions or input.

    #2
    Looks right to me

    What are you expecting to see??

    date = {05/17/2006}
    Month_start = {05/01/2006} which is the first day of the month of Date()
    Add_bus_days({05/01/2006},1) adds 1 bus day which = {05/02/2006}

    This is all correct. If you explain what you need, we can help better.

    Scott

    Comment


      #3
      Originally posted by Scott Emerick
      What are you expecting to see??

      date = {05/17/2006}
      Month_start = {05/01/2006} which is the first day of the month of Date()
      Add_bus_days({05/01/2006},1) adds 1 bus day which = {05/02/2006}

      This is all correct. If you explain what you need, we can help better.

      Scott
      Also you have to set up the holiday dates in the built-in holiday table or create your own and you have to set the ignore holiday flag to something other than null.

      ? add_bus_days({09/01/2006},1,"N")
      = {09/05/2006}
      There can be only one.

      Comment


        #4
        Using this function add_bus_day(month_start(date(),1) with system date set to 01/01/2006 the result is 01/02/2006 which is the first business day of the month January 2006.

        Using this function add_bus_day(month_start(date(),1) with system date set to 02/01/2006 the result is 02/02/2006 which is the second business day of the month February 2006.

        The function in both cases should return the ether the 1st or the 2nd business day of thier respective months?

        Thanks for your help?

        Comment


          #5
          What I am attempting to do is to make work day only calendars form using the system date and the month_start function to start the begining date for each of the 20 - 22 fields for the month. But I'am not getting any consistency from the function. The holiday.dbf is setup with hollidays that match the US Post Office.

          I have each field setup on initiate and it fills in the header for each work day of the month. The only difference in each function is the day of the month is the number of days to add.
          add_bus_days(month_start(date()),0) = day1
          add_bus_days(month_start(date()),1) = day2
          add_bus_days(month_start(date()),2) = day3
          and so on....

          I did a small example of what I am getting as results. from the add_bus_days funtion.

          Using this function add_bus_day(month_start(date(),1) with system date set to 01/01/2006 the result is 01/02/2006 which is the first business day of the month January 2006.

          Using this function add_bus_day(month_start(date(),1) with system date set to 02/01/2006 the result is 02/02/2006 which is the second business day of the month February 2006.

          The function in both cases should return the ether the 1st or the 2nd business day of thier respective months?

          I did some more diagnostics and futher found that the function almost works when you start the function with 0 add on days. It does for February 2006 but not for January 2006

          Thanks for your help?

          Comment


            #6
            Using this function add_bus_day(month_start(date(),1) with system date set to 01/01/2006 the result is 01/02/2006 which is the first business day of the month January 2006.

            Using this function add_bus_day(month_start(date(),1) with system date set to 02/01/2006 the result is 02/02/2006 which is the second business day of the month February 2006.

            The function in both cases should return the ether the 1st or the 2nd business day of thier respective months?
            I don't accept your premise. These functions don't test whether the first day of the month is itself a business day. All they do in your expressions is begin with the first day of the month, and then add one business day. They seem to be working as intended. Either you need to account for the fact that the first day of the month is or is not a business day, or I guess I need to learn what I'm missing.

            why not start with the last day of the previous month ?

            Alternatively, why not step through all the days of each month discarding those that are not business days ?

            -- tom

            Comment


              #7
              Originally posted by reedorbs
              What I am attempting to do is to make work day only calendars form using the system date and the month_start function to start the begining date for each of the 20 - 22 fields for the month. But I'am not getting any consistency from the function. The holiday.dbf is setup with hollidays that match the US Post Office.

              I have each field setup on initiate and it fills in the header for each work day of the month. The only difference in each function is the day of the month is the number of days to add.
              add_bus_days(month_start(date()),0) = day1
              add_bus_days(month_start(date()),1) = day2
              add_bus_days(month_start(date()),2) = day3
              and so on....

              I did a small example of what I am getting as results. from the add_bus_days funtion.

              Using this function add_bus_day(month_start(date(),1) with system date set to 01/01/2006 the result is 01/02/2006 which is the first business day of the month January 2006.


              The function in both cases should return the ether the 1st or the 2nd business day of thier respective months?

              I did some more diagnostics and futher found that the function almost works when you start the function with 0 add on days. It does for February 2006 but not for January 2006

              Thanks for your help?
              I responded to your private message separately but for anyone else who is interested, the add_bus_days() function explicitly prohibits the use of zero as the second parameter so I am not surprised by the inconsistency.

              I am struggling with the question at hand.


              Using this function add_bus_day(month_start(date(),1) with system date set to 01/01/2006 the result is 01/02/2006 which is the first business day of the month January 2006.
              January 2, 2006 is a Monday which is the first business day after Jan 1, 2006 - we're right here.

              Using this function add_bus_day(month_start(date(),1) with system date set to 02/01/2006 the result is 02/02/2006 which is the second business day of the month February 2006.
              Feb 2, 2006 is a Thursday, the first business day after Feb 1, 2006 so we're ok here.

              The function in both cases should return the ether the 1st or the 2nd business day of thier respective months?
              - should and does.

              I don't see what the issue is.
              There can be only one.

              Comment


                #8
                The first business day of February 2006 is WED not Thursday

                The first business day of February 2006 is WED.

                That's the problem.

                Thanks for your input, any ideas?

                Comment


                  #9
                  This is what I figured out to create a Monthly Work Day Calendar, and yes Zero does work on the add_bus_days function. I saw the relationship of the function changing with the first day starting on a week-end when I was explaining how the add_bus_days function was inconsistent.

                  'Set 'Value' property of 'Day1' .
                  DIM form_name as c
                  Dim weekday as c
                  if is_object(topparent.this) then
                  form_name = topparent.name()+".this"
                  else
                  form_name = ""
                  end if

                  weekday = cdow(month_start(date()))

                  IF is_one_of(weekday,"Saturday"+crlf()+"Sunday"+crlf())THEN
                  DELETE expression_result
                  expression_result = eval("add_bus_days(month_start(date()),1)",form_name)
                  topparent:Day1.value = expression_result
                  END IF

                  IF is_one_of(weekday,"Monday"+crlf()+"Tuesday"+crlf()+"Wednesday"+crlf()+"Thursday"+crlf()+"Friday"+crlf())THEN
                  DELETE expression_result
                  expression_result = eval("add_bus_days(month_start(date()),0)",form_name)
                  topparent:Day1.value = expression_result
                  END IF

                  Comment


                    #10
                    For each field in the Calendar header you copy the code and then increment the previous Saturday Sunday Add_Days by 1 or matching it to the number of the work day in the month as well as incrementing the Monday - Friday Add_days by 1 which will always be 1 less than that of the previous.

                    Comment


                      #11
                      Originally posted by reedorbs
                      For each field in the Calendar header you copy the code and then increment the previous Saturday Sunday Add_Days by 1 or matching it to the number of the work day in the month as well as incrementing the Monday - Friday Add_days by 1 which will always be 1 less than that of the previous.
                      I think you solved your issue. Here's a function which returns a crlf() delimited list of business days in the month of any given date, I think.

                      Code:
                      FUNCTION bus_list AS C (seed AS D )
                      dim st as n
                      dim nd as n
                      dim day_before as d
                      dim bus_days as c
                      st = day(month_start(seed))
                      nd = day(month_end(seed))
                      day_before = month_start(seed)-1
                      bus_days = ""
                      for i = st to nd
                      	if month(add_bus_days(day_before,i)) = month(seed)
                      	bus_days = bus_days + ","+dtoc(add_bus_days(day_before,i))
                      	end if
                      next i
                      bus_days = stritran(bus_days,",","",1,1)
                      bus_list = stritran(bus_days,",",crlf()) 
                      END FUNCTION
                      Sample output

                      Code:
                      ? bus_list({01/01/2006})
                      = 01/02/2006
                      01/03/2006
                      01/04/2006
                      01/05/2006
                      01/06/2006
                      01/09/2006
                      01/10/2006
                      01/11/2006
                      01/12/2006
                      01/13/2006
                      01/16/2006
                      01/17/2006
                      01/18/2006
                      01/19/2006
                      01/20/2006
                      01/23/2006
                      01/24/2006
                      01/25/2006
                      01/26/2006
                      01/27/2006
                      01/30/2006
                      01/31/2006
                      There can be only one.

                      Comment


                        #12
                        Cool, Thanks,

                        I did solve my own results, but still not sure that the function add_bus_days works properly between months.

                        Comment

                        Working...
                        X