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

Calculating how many days without negative numbers

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

    Calculating how many days without negative numbers

    I would like to make an expression showing how many days a car has been on he the lot, and break it down by the month and if a partial month just the number of days for that month and show 0 for the rest of the each month thank you

    #2
    Have you tried making the expression?
    If so, give us a look please.
    See our Hybrid Option here;
    https://hybridapps.example-software.com/


    Apologies to anyone I haven't managed to upset yet.
    You are held in a queue and I will get to you soon.

    Comment


      #3
      It's relatively easy. Even easier if you're willing to use a helper column/function.
      With that said, my solution is based on dates with the mm/dd/yyyy format, but that can be worked around.
      As Ted suggested, it's definitely good to know more about what you've tried ( dateGone - dateArrived) should get
      you extremely close to your answer depending on the details.
      Gregg
      https://paiza.io is a great site to test and share sql code

      Comment


        #4
        stordays = date()-Todaysdate
        j1 = calc->Stordays-Jandays
        f1 = calc->Stordays-Jandays-Febdays
        m1 = calc->Stordays-Jandays-Febdays-Mardays
        a1 = calc->Stordays-Jandays-Febdays-Mardays-Aprdays
        ma1 = calc->Stordays-Jandays-Febdays-Mardays-Aprdays-Maydays
        j1 = calc->Stordays-Jandays-Febdays-Mardays-Aprdays-Maydays-Jundays
        ju1 = calc->Stordays-Jandays-Febdays-Mardays-Aprdays-Maydays-Jundays-Juldays
        au1 = calc->Stordays-Jandays-Febdays-Mardays-Aprdays-Maydays-Jundays-Juldays-Augdays
        s1 = calc->Stordays-Jandays-Febdays-Mardays-Aprdays-Maydays-Jundays-Juldays-Augdays-Sepdays
        n1 = calc->Stordays-Jandays-Febdays-Mardays-Aprdays-Maydays-Jundays-Juldays-Augdays-Sepdays-Octdays-Novdays
        d1 = calc->Stordays-Jandays-Febdays-Mardays-Aprdays-Maydays-Jundays-Juldays-Augdays-Sepdays-Octdays-Novdays-Decdays

        This is the only way I know how, I am not very smart to xbasic. As you can see everything works until april then it starts in the negative
        The stordays right now =117

        Comment


          #5
          I know I did not do something very smart I named a field todaysdate, with that being said everything is subtracting properly from 117 then in april their is only 4 days left but it puts a negative sign, and the following months should have zero or blank

          Comment


            #6
            Hi Deputy,
            It looks like you're using Todaysdate as the beginning date of storage.
            I'm not sure what the purpose of j1,f1, m1 .. and so on are for, but it looks like you're missing o1.
            It looks like you your stordays = 117 is considering every day of 2024 a storage day through April 28, 2024, but I don't think that's the information you're actually after.

            If you don't have any of the actual coding done yet, maybe an example of the data and what you expect the results should be will give us a shove in the right direction.

            Maybe this image will help with what you want to do.
            image.png
            Gregg
            https://paiza.io is a great site to test and share sql code

            Comment


              #7
              the field name Todaydate should have been Towdate, saying that I take Date() - Todaysdate that give me how many days the car has been on the lot, the Todaysdate is 01/02/2024 thats gives me 117 days on the lot, now I want to break it down based on how many days on the lot per month, with that in mind j1 is january 31 day, f1 is febuary 29 days, m1 is march 31 days a1 is april 4 days, these numbers add up to 117 days, but in april it starts to give me negative numbers and on the rest of the months

              Comment


                #8
                I'd like to see the code/page that is giving you negative numbers.
                You definitely need a simple if/then to prevent negative numbers.
                Gregg
                https://paiza.io is a great site to test and share sql code

                Comment


                  #9
                  You have stated the problem and how you are trying to calculate a result.
                  I take it that something like;

                  ​​​​​Tow Date = 21/01/2024
                  Jan 10 days
                  Feb 29 days
                  Mar 31 days
                  Apr 29 days

                  Sum()uIs this assumption correct?

                  If you have time, please humour me and let us know where this data is to be used.
                  Report, Screen, Email, Invoice?

                  It may simplify the way a calc is created.
                  See our Hybrid Option here;
                  https://hybridapps.example-software.com/


                  Apologies to anyone I haven't managed to upset yet.
                  You are held in a queue and I will get to you soon.

                  Comment


                    #10
                    Thank you for all your help, as I said i am not a coder. I have a field called towdate, I also have the 12 fields which are listed above they are the months of the year, each field has the numeric days of the month for example j1 is January theire is a numeric value in the field of 31 because that is how many days in that month. So if I have a car on the lot for 5 months I would need to print for each month how long the car has been on the lot, example J1 would be 31, f1 would be 29 and so on, but if a car has been only on a lot for 20 days and that month only has 30 days it would print a -20 instead of just 20 and for the rest of the months on the year it would print negative numbers instead of showing 0

                    Comment


                      #11
                      This is like pulling hens teeth. ( see my signature )
                      post a picture of your form, report, whatever, showing the layout and negatives.
                      See our Hybrid Option here;
                      https://hybridapps.example-software.com/


                      Apologies to anyone I haven't managed to upset yet.
                      You are held in a queue and I will get to you soon.

                      Comment


                        #12
                        Let me try this way, all I want to do is find out how long a car was on the lot and broke down by the month that it. Is their a expression than can do this forget about what I have

                        Comment


                          #13
                          This is being made far more difficult than it needs to be.
                          We know a car there for the full month is easy to deal with.
                          That means we need to deal with partial months, which have 3 scenarios.
                          A. Arrive after the 1st and stay the rest of the month.
                          B. Arrive on or before the first and leave before the end of the month.
                          C. Arrive after the 1st and leave before the end of the month.

                          I can do this easily enough (same concept as the warehousing app I have), but I have no idea what you're working with.
                          There are times when non-coders should pay the coders for their knowledge and get the job done.
                          I'm easily available most times of the day to do a quick assist/zoom/teams meeting.

                          Gregg
                          https://paiza.io is a great site to test and share sql code

                          Comment


                            #14
                            Deputy...look at post #6. I put all the code in there, but it might need you to tweak the way you're doing things depending on how frequently you run this app (daily, monthly, annually).
                            Gregg
                            https://paiza.io is a great site to test and share sql code

                            Comment


                              #15
                              Hi all,
                              I agree it is not difficult but it is slightly complicated. There is a start date and end date (today) and the difference is the total on-lot quantity of days. The tricky part is to achieve a result that was asked, which is to have the result broken down with the quantity of days within each on-lot month. There may be an expression that can be concocted for this but I'm not confident there is and that it will be less than 1024 character in length. However a function is always available.

                              Code:
                              'RUN REPORT
                              dim vd_towdate as D=ctod("11/10/2023")
                              on_lot_report(vd_towdate)
                              
                              FUNCTION on_lot_report as C (towdate as D)
                              
                              dim vd_today as D=date()
                              dim vd_towdate as D=towdate
                              dim vn_mo as N=month(vd_towdate)
                              dim vn_yr as N=year(vd_towdate)
                              'msgbox("14",(""+vn_mo)+" - "+(""+vn_yr));end
                              
                              dim vn_onlot_days_total as N=date()-vd_towdate
                              dim vn_no_of_months as N
                              dim vn_onlot_days_mo as N
                              dim vn_days_remain as N=vn_onlot_days_total
                              
                              dim vd_now as D=vd_towdate
                              dim vd_mo_end as D
                              
                              dim vc_mo as C
                              dim vn_mo_onlot_days as N
                              
                              dim vLcol as C=""
                              'msgbox("28",(""+vn_mo)+crlf()+(""+vn_yr))
                              
                              'DETERMINE NO MO
                              vn_no_of_months=round_up(vn_onlot_days_total/12,0)
                              
                              FOR i = 1 to vn_no_of_months
                              
                              'MAKE DATE FOR ITERATION CALCULATIONS
                              if i = 1
                              vd_now=vd_towdate
                              vn_mo=month(vd_now)
                              else
                              'IN AN ITERATION
                              vn_mo=vn_mo+1
                              
                              'TEST FOR A YEAR LAPSE
                              if vn_mo > 12
                              vn_mo=1
                              vn_yr=vn_yr+1
                              end if
                              vd_now=ctod((""+vn_mo)+chr(47)+"01"+chr(47)+(""+vn_yr))
                              'msgbox("38",(""+vd_now))
                              end if
                              
                              'GET CHAR MONTH NOW
                              vc_mo=left(cmonth(vd_now),3)
                              
                              'GET THE NOW MONTH END DATE
                              vd_mo_end=month_end(vd_now)
                              
                              'GET THE NUMBER OF DAYS IN THE MONTH AVAILABLE FOR ON LOT
                              vn_mo_days_avail=vd_mo_end-vd_now
                              if i > 1
                              vn_mo_days_avail=vn_mo_days_avail+1
                              end if
                              'msg("63",(""+vd_mo_end)+" - "+(""+vd_now)+crlf()+(""+vn_mo_days_avail)+crlf()+(""+vn_days_remain))
                              
                              'TEST TO DETERMINE IF THE QUANTITY OF REMAINING DAYS EXCEEDS THE QUANTITY OF AVAILABLE DAYS IN THE MONTH
                              'IF THE QUANTITY OF REMAINING DAYS EXCEEDS THE QUANTITY OF AVAILABLE DAYS -> ALL THE DAYS IN THE MONTH USED AND ITERATION INTO THE NEXT MONTH NEEDED
                              
                              if vn_days_remain < vn_mo_days_avail
                              
                              'THIS MAKES THE EXPIRATION OF THE DAYS REMAINING AND THE END REACHED AND NO MORE ITERATIONS NEEDED
                              vn_onlot_days_mo=vn_days_remain
                              vLcol=vLcol+vc_mo+"["+(""+vn_onlot_days_mo)+"]"+crlf()
                              EXIT FOR
                              else
                              'THIS MAKES ANOTHER ITERATION NEEDED -> ADD THE CURRENT MONTHS ON LOT DAYS TO THE COLLECTION AND GENERATE ANOTHER ITERATION
                              vn_onlot_days_mo=vn_mo_days_avail
                              vn_days_remain=vn_days_remain-vn_onlot_days_mo
                              vLcol=vLcol+vc_mo+"["+(""+vn_onlot_days_mo)+"]"+crlf()
                              end if
                              
                              NEXT
                              
                              'INCLUDE TOTAL
                              vLcol=vLcol+"======"+crlf()+"Total= "+(""+vn_onlot_days_total)
                              
                              'DISPLAY RESULTS
                              msgbox("Results",vLcol)
                              
                              END FUNCTION​
                              Last edited by Mike Wilson; 05-04-2024, 02:52 PM.
                              Mike W
                              __________________________
                              "I rebel in at least small things to express to the world that I have not completely surrendered"

                              Comment

                              Working...
                              X