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

Need Help With a Date Based Expression

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

    Need Help With a Date Based Expression

    I am creating ID cards using a report based on an active link table in a MySQL DB. I need to show an expiration date on the cards and it will always be April 30th of the next April.

    What I need to do is calculate the next April 30th. In other words I need some kind of conditional statement that says if it's between May 1st and Dec. 31st it should be April 30, "current Year + 1, if it's between Jan 1st and April 30 it should be April 30, current year.

    Can someone give me an idea of how to do this? I have tried several methods and none give me what I need.

    Thanks.

    #2
    Re: Need Help With a Date Based Expression

    Code:
    DIM vDateD as D
    vDateD = {05/01/2010}
    
    ?IF(vDateD <= convert_type("{04/30/"+year(vDateD)+"}","date"),"{04/30/"+year(vDateD)+"}","{04/30/" + (year(vDateD)+1) +"}")
    = "{04/30/2011}"
    
    
    vDateD = {04/01/2010}
    
    ?IF(vDateD <= convert_type("{04/30/"+year(vDateD)+"}","date"),"{04/30/"+year(vDateD)+"}","{04/30/" + (year(vDateD)+1) +"}")
    = "{04/30/2010}"
    Andrew

    Comment


      #3
      Re: Need Help With a Date Based Expression

      Just a quick-one (at the brain-stem level i.e., not much thought put into it):

      Code:
      dim x as d={01/01/2010}
      ?date_value(if(month(x)<5,year(x),year(x)+1),4,30)
      = {04/30/2010}
      x={05/01/2010}
      ?date_value(if(month(x)<5,year(x),year(x)+1),4,30)
      = {04/30/2011}
      When my cerebrum is back at work, I might come up with something else.

      Comment


        #4
        Re: Need Help With a Date Based Expression

        With the cerebellum awakening, if the date is:
        01/01/1999
        What date do you want? April 30 of 2010? or 1999?
        And what if the date:
        11/1/1999 ?

        Comment


          #5
          Re: Need Help With a Date Based Expression

          I'll answer my own questions before I drift into comma:
          Code:
          delete x
          dim x as d={01/01/2010}
          ?if(x<date_value(year(date()),4,30),date_value(year(date()),4,30),date_value(year(x)+1,4,30))
          = {04/30/2010}
          x={01/01/1999}
          ?if(x<date_value(year(date()),4,30),date_value(year(date()),4,30),date_value(year(x)+1,4,30))
          = {04/30/2010}

          Comment


            #6
            Re: Need Help With a Date Based Expression

            Originally posted by G Gabriel View Post
            With the cerebellum awakening, if the date is:
            01/01/1999
            What date do you want? April 30 of 2010? or 1999?
            And what if the date:
            11/1/1999 ?
            The date would never be in the past.

            This would not be a stored date. It would only be used at runtime for printing the current ID card or membership card. If the user prints a card between May 1 and Dec 31 of this year (2010) it should print April 30, 2011 and likewise between Jan 1 and April 30 of 2011. After May 1 2011, it should print April 30, 2012, etc..

            Comment


              #7
              Re: Need Help With a Date Based Expression

              I had assumed, by way of extrapolation, that the date is either current or future.
              Either one of the above suggestions should work.

              Comment


                #8
                Re: Need Help With a Date Based Expression

                Doug,
                Do you need this as a single line expression or can it be a if--then or select--case ?? This should always be stated---otherwise, the first will work regardless of context, but the other two will not say in the expression builder and such.

                Maybe
                Code:
                if(between(date(),ctod("05/01/"+str(year(date()))),ctod("04/30/"+str(year(date())+1))),ctod("04/30/"+str(year(date())+1)),ctod("04/30/"+str(year(date())+2)))
                Mike
                __________________________________________
                It is only when we forget all our learning that we begin to know.
                It's not what you look at that matters, it's what you see.
                Henry David Thoreau
                __________________________________________



                Comment


                  #9
                  Re: Need Help With a Date Based Expression

                  I think it could be either. I want to use it in a report as a calculated field.

                  Comment


                    #10
                    Re: Need Help With a Date Based Expression

                    A single line as I gave would be what is needed then....did you try my guess?
                    Mike
                    __________________________________________
                    It is only when we forget all our learning that we begin to know.
                    It's not what you look at that matters, it's what you see.
                    Henry David Thoreau
                    __________________________________________



                    Comment


                      #11
                      Re: Need Help With a Date Based Expression

                      Yes Mike, it seemed to work great as I tried various dates until I tried Mar 2, 2012 and it came up with April 30, 2014 instead of 2013. I'll take a look at it closer tomorrow to see if I can tell why. It has to be the +2 part kicking in.

                      Your suggestion seems to have pointed me in the right direction. Thank You.

                      Comment


                        #12
                        Re: Need Help With a Date Based Expression

                        Doug,
                        The function I gave assumed that you would be dealing with current dates.....if only the month and day are to be considered and the date you are testing is to be placed into the function as an argument, then that changes the function somewhat (although it would be similar).
                        Mike
                        __________________________________________
                        It is only when we forget all our learning that we begin to know.
                        It's not what you look at that matters, it's what you see.
                        Henry David Thoreau
                        __________________________________________



                        Comment


                          #13
                          Re: Need Help With a Date Based Expression

                          Mike, it should be based on the current system date. I experimented with changing the system date and running the report to see what it would print.

                          Comment

                          Working...
                          X