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

Understanding a simple date calculation

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

    Understanding a simple date calculation

    Using the latest version of v8:

    Year1 = {1/10/(year(date())} returns D:1/10/2009
    Year2 = (year(date())-1) returns N:2008
    Year3 = {1/10/year(date())-1} returns D:1/10/2001
    Year4 = str("1/10/"+(year(date())-1)) returns C:1/10/2008
    Year5 = ctod(str("1/10/"+(year(date())-1))) returns D:1/10/2008

    This all makes perfect sense except Year3. Why does it return D:1/10/2001 when I expect D:1/10/2008? It's not that I can't work around it, but if I understand why A5 does this I'll avoid duplicating the problem in the future.

    Thanks
    Alan
    Kind Regards
    Alan

    #2
    Re: Understanding a simple date calculation

    Hi Alan,

    Originally posted by Citadel View Post
    Using the latest version of v8:

    Year1 = {1/10/(year(date())} returns D:1/10/2009
    Year2 = (year(date())-1) returns N:2008
    Year3 = {1/10/year(date())-1} returns D:1/10/2001
    Year4 = str("1/10/"+(year(date())-1)) returns C:1/10/2008
    Year5 = ctod(str("1/10/"+(year(date())-1))) returns D:1/10/2008

    This all makes perfect sense except Year3. Why does it return D:1/10/2001 when I expect D:1/10/2008? It's not that I can't work around it, but if I understand why A5 does this I'll avoid duplicating the problem in the future.
    You can't put expressions within a date constant like {mm/dd/yyyy}, only numbers where they are supposed to be. Leaving out yyyy gives you the current year. if you want to add months or years, easiest way to do it is addmonths() and addyears() functions. Days can be simply added or subtracted after a date value, as in {01/10/2009}-3

    You are also mixing numbers, dates and strings and using them for the wrong functions that don't accept those types. A5 will convert to strings in some cases, but it's a bad thing to count on. str() requires a number inside, ctod() a string that looks like a date

    Look at the examples in the help file under date time conversions.
    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


      #3
      Re: Understanding a simple date calculation

      Alan, I think you've written an expression Alpha can't decipher, and then the Setting for 21st century dates kicks in. Consider this:

      ?{1/10/year(date())-50}
      = {01/10/1950}

      and

      ?{01/01/1}
      = {01/01/2001}

      Comment


        #4
        Re: Understanding a simple date calculation

        Originally posted by Citadel View Post
        This all makes perfect sense except Year3. Why does it return D:1/10/2001 when I expect D:1/10/2008? It's not that I can't work around it, but if I understand why A5 does this I'll avoid duplicating the problem in the future
        Alan:
        Your first post.. so let me be the first to welcome you aboard.. and also the first to hand you the trophy for creative imagination..unfortunately, it does not work. I mean: the creative imagination.

        Don't know how much experience you have with alpha, but to test any expression, you could go to the Interactive Window and type your expression preceded by a question mark, hit enter and you will see the result.

        So let's do that:
        Code:
        ?{1/10/year(date())} 
        = {01/10/2009}
        Which is what you got. And, quite logically you concluded that alpha took the year from date() and that's how you ended up with that result with the year 2009.

        Not so.

        Alpha completley ignored everything you wrote that you think will evaluate to the year. It all added up to nothing since it had no numerals in it.

        To understand, let's try few things:

        Code:
        ?{1/10/junk} 
        = {01/10/2009}
         Same result.
        Code:
        ?{1/10/Uncle Jody Had a cat} 
        = {01/10/2009}
        same result
        Code:
        ?{1/10/Uncle Jody Had [B][COLOR="Blue"]1[/COLOR][/B] cat} 
        = {01/10/200[B][COLOR="Blue"]1[/COLOR][/B]}
        Code:
        ?{1/10/Uncle Jody Had [B][COLOR="Blue"]5[/COLOR][/B] cats} 
        = {01/10/200[COLOR="Blue"][B]5[/B][/COLOR]}
        'Same as:
        ?{1/10/5} 
        = {01/10/2005}
        ?{1/10/05} 
        = {01/10/2005}
        ?{1/10/2005} 
        = {01/10/2005}
        You get the idea?
        Alpha is looking for a numeral representative of the year, everything else is ignored. When no numeral is found, it's the equivalent of blank and blank defaults to the current year.

        Comment


          #5
          Re: Understanding a simple date calculation

          Let's push this creative imagination a little further and push alpha's buttons:
          Code:
          ?{1/1/Uncle Jody had 123 cats}
          = {01/01/0123}
          ?{1/1/Uncle Jody had 1234 cats}
          = {01/01/1234}
          ?{1/1/Uncle Jody had 12345 cats}
          ERROR: Invalid date constant
          ?{1/1/Uncle Jody had 123 cats and 5 dogs}
          = {01/01/0123}
          ?{1/1/Uncle Jody had 12345 cats and 5 dogs}
          ERROR: Invalid date constant
          ?{1/1/Uncle Jody had 1,234 cats}
          = {01/01/2001}
          ?{1/1/Uncle Jody had 12,234 cats}
          = {01/01/2012}
          "Can you see how alpha is deciphering the year?
          Code:
          ?{Uncle Jody had 1 cat/1/2009}
          ERROR: Invalid date constant
          'Hmmmm?
          Code:
          ?{1 cat is all you need/1/2009}
          = {01/01/2009}
          Code:
          ?{1 cat is all you need/1 dog too/2009}
          = {01/01/2009}
          Code:
          ?{1 cat is all you need/3 dogs even better/2009}
          = {01/03/2009}
          Last edited by G Gabriel; 04-07-2009, 07:26 PM.

          Comment


            #6
            Re: Understanding a simple date calculation

            G, I like your reasoning, but want to quibble with your conclusion. Alpha does not default to the current year. 2001 is not the current year after all. Alpha uses the database's two digit date setting to conclude that year 1 is in the 21st century. The number 1 following the ignored text is what is significant, as you indicate, but then Alpha translates 1 into 2001 not by default but by observing the database setting for 2 digit years falling between 00 and 20. Since 50 is outside the typical 2 digit range, you get 1950, not 2050, if the 1 is replaced by 50. See what I mean?

            Comment


              #7
              Re: Understanding a simple date calculation

              Tom:
              Not sure how you get 2001:
              Code:
              ?{1/1}
              = {01/01/2009}
              ?{1/1/}
              = {01/01/2009}
              ?{1/1/        }
              = {01/01/2009}
              In fact, one of my tricks to get the current year in a variable is to evaluate one with a blank year. It will always take the current year:
              Code:
              dim x as c
              x="{1/1}"
              ?eval(x)
              = {01/01/2009}
              'How about it?
              The reason you got 1950 not 2050 is because (as many databases do) alpha could go so far in the future.
              To see what I mean:
              Code:
              ?{1/10/year(date())-50}
              = {01/10/1950}
              ?{1/10/year(date())-10}
              = {01/10/2010}
              'Hmmm?
              ?{1/10/year(date())-11}
              = {01/10/2011}
              'Hmmm again?
              ?{1/10/year(date())-20}
              = {01/10/1920}
              'Same Hmmm?
              ?{1/10/year(date())-21}
              = {01/10/1921}
              'Different Hmmm?.
              Last edited by G Gabriel; 04-07-2009, 07:44 PM.

              Comment


                #8
                Re: Understanding a simple date calculation

                G, I get it per post #3 in this thread...

                I thought you understood that his original question did in fact include the numeral 1 in the year position, albeit trailing a series of non-numeric characters and symbols. Year3 = {1/10/year(date())-1}
                That's why he got the result he obtained, and why you get 01/01/1950 if your expression looks like this:
                Year3 = {1/10/year(date())-50}

                BTW, I chuckle each time someone uses the word "simple" when describing an issue involving programming or computers.... Here, the topic name cracks me up. <grin>

                Comment


                  #9
                  Re: Understanding a simple date calculation

                  Originally posted by Tom Cone Jr View Post
                  G, I get it per post #3 in this thread...

                  I thought you understood that his original question did in fact include the numeral 1 in the year position, albeit trailing a series of non-numeric characters and symbols. Year3 = {1/10/year(date())-1}
                  That's why he got the result he obtained, and why you get 01/01/1950 if your expression looks like this:
                  Year3 = {1/10/year(date())-50}
                  Tom:
                  I think you missed one of my earlier posts..
                  To wit:
                  Alpha is looking for a numeral respresentative of the year.
                  Year3 = {1/10/year(date())-1} does have a numeral which is 1 hence you got 2001. But if it didn't have any numeral, to alpha, it's the equivalent of leaving the year number blank and if you do alpha will default to the current year. Read posts 5&7 for illustration.

                  Comment


                    #10
                    Re: Understanding a simple date calculation

                    While we are on that subject ...kindof... then how about time as well. Does Alpha also expect the same as there are date and time combinations in the functions as well ?

                    Comment


                      #11
                      Re: Understanding a simple date calculation

                      Hi Ryland,

                      Originally posted by [email protected] View Post
                      While we are on that subject ...kindof... then how about time as well. Does Alpha also expect the same as there are date and time combinations in the functions as well ?
                      There are many types, Character, Numeric, Logical, Blob, Date, Date-Time, Short Time, Pointer, as well as a few other types. Each function can only take the types it was made for.
                      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: Understanding a simple date calculation

                        Thank you all for the welcome and replies. I've been dipping in and out of the forum for a couple of years now, but just reading. The posts always seem to be so well informed, and I have a high regard for your professionalism.

                        I think I got the idea that functions could accept different data types because A5 usually seems to cleverly 'autoconvert' data in variables to match the expected data type.

                        I will have to be more careful in future.

                        Thanks again
                        Alan
                        Kind Regards
                        Alan

                        Comment

                        Working...
                        X