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

Logical value for a date field

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

    Logical value for a date field

    Help, anyone.

    I'm trying to create a "conditional image control" placed on a grid that is based on a time field (StartTime). If StartTime is blank, I want a white button image to display. For the life of me, I'm not getting it. Apparently, I'm not coming up with the correct Logical Syntax. These are a few of my attempts:

    Code:
    StartTime = ""
    dtoc(StartTime)= ""
    alltrim(dtoc(StartTime,"1/",.t.))=""
    convert_type(StartTime,"C")=""
    I'm currently using the code -- convert_type(StartTime,"C")="". It's a server side validation, so I'm using xbasic. I know the data is blank because it shows blank, as seen in the first record in my screen shot. The red button also makes me assume Alpha believes it is a sooner date than today's date because the code for a red button is if StartTime is before today.

    It works in the Interactive window. This is what I get:
    dim d as t
    d={}
    ?convert_type(d,"c")
    = ""

    Any help would be appreciated before I run my head through the door over such a seemingly stupid little thing.
    Attached Files
    Brad Steinfeldt

    #2
    Re: Logical value for a date field

    I'm not seeing an issue with this... but I don't think there's enough information. E.g. Alpha version/build, database...e.g. sql? Is your field a date, datetime, or time datatype? Could you show a screenshot of the conditions created? Using datetime the following conditions produce these results...

    gridCond1.PNG

    gridCond2.PNG

    Ensure that your empty test is 1st in the list of conditions. You get very different results depending on the order.
    Last edited by Davidk; 01-16-2019, 05:04 PM.

    Comment


      #3
      Re: Logical value for a date field

      thanks for the reply:

      my version: 12.4.5.4.7 build 5487
      Data: SQL using MS Access 2010.
      Field is a Date/Time using "General Date" format.

      Here's the field details.
      2019-01-16 (1).png

      I didn't try using the sql connection in the interactive window to see how the code was affecting the data; I don't know enough about sql code to do it.
      Brad Steinfeldt

      Comment


        #4
        Re: Logical value for a date field

        Using an Access database, try a conditional expression using "C" for a blank test and "D" for a date test...

        gridCond3.PNG

        Comment


          #5
          Re: Logical value for a date field

          David,

          Thanks again. I tried it-- one of my attempts was 'convert_type(StartTime,"C")="".' The screenshot I sent was with that code, and the result was a red button (or StartTime<Date()). I even attempted alltrim(convert_type(StartTime,"C")).

          I'm pretty sure it has to do with using Access because I did this years ago with an Alpha DBF table, and it worked without a problem.

          How do I get the data from the StartTime field using SQL in the Interactive window? When I look at it in Access, it is just blank, like I would expect, but maybe it's different when reading it from within Alpha in the Interactive window. My knowledge of SQL commands is limited, so I've used the genie to produce this:

          Code:
          'Execute a query on a SQL database
          'DIM a connection variable
          DIM cn as SQL::Connection
          dim flagResult as l 
          flagResult = cn.open("::Name::Landscape Estimator")
          if flagResult = .f. then 
          	ui_msg_box("Error","Could not connect to database. Error reported was: " + crlf() + cn.CallResult.text)
          	end 
          end if
          
          'Specify if you are using Portable SQL syntax, or not
          cn.PortableSQLEnabled = .t. 
          dim sqlStatement as c 
          sqlStatement = <<%sql%
          [COLOR="#FF0000"]SELECT StartTime  FROM Events  WHERE EventId = 37102
          [/COLOR]%sql%
          'Execute the Query
          flagResult = cn.Execute(sqlStatement)
          if flagResult = .f. then 
          	ui_msg_box("Error",cn.CallResult.text)
          	cn.close()
          	end 
          end if 
          dim rs as sql::resultset
          rs = cn.ResultSet
          'The sql_resultset_preview() function opens a window showing a table with the results
          'of your query. Show a maximum of 1,000 rows of data
          'Note that the connection object is passed into the sql_resultset_preview() function so that the
          'function can immediately release the resultset, thereby releasing any locks on the database that some databases might
          'have applied.
          sql_resultset_preview(rs,1000,"Preview Query Results",cn)	
          
          	'Now, close the connection 
          cn.close()
          I know the record (#37102) I selected has a blank StartTime field, but I don't know the SQL to put it into a variable so I can see the attributes in the Interactive Window. I'm just thinking if I can do that, I'll see how it's shown. Do you know and is that the next place I'd go?

          thanks again,
          Brad Steinfeldt

          Comment


            #6
            Re: Logical value for a date field

            You'll need to show a screenshot of ALL your Conditional Image conditions. The only other process, apart from guessing, would be for you to zip and post a sample Access table and a sample Grid showing the issue.

            Comment


              #7
              Re: Logical value for a date field

              Here's a screenshot of all my Conditional Image conditions.
              2019-01-17.png

              Should I just evaluate on the client-side? Is it possible? I don't know javascript much, so server-side is much easier for me, and it seems to be able to handle more powerful functions.

              If this doesn't help, I'll package a sample and send it back, but I might not be able to send it back until tomorrow.

              Thanks again for your help.
              Brad Steinfeldt

              Comment


                #8
                Re: Logical value for a date field

                Opps, that wasn't the correct screenshot... I think I must have copied yours. This is the correct one...
                2019-01-17 (1).png
                Brad Steinfeldt

                Comment


                  #9
                  Re: Logical value for a date field

                  It seems that your condition code is overly complicated. I don't think you need all that dtoc stuff.

                  It's the order of your conditions that is causing your issue. As I mentioned earlier, you must place your "blank" condition at the top the list...

                  gridCond4.PNG

                  gridCond5.PNG

                  These simpler conditions produce the same results.

                  gridCond6.PNG

                  It's also a bit unclear if you're working with Date AND Time... or just a Date. What does your actual data look like within the Access table?
                  Last edited by Davidk; 01-17-2019, 04:44 PM.

                  Comment


                    #10
                    Re: Logical value for a date field

                    That did it!

                    Thank you, and my head and wall also thank you since they are no longer in jeopardy.

                    It must have been the order. I'm sorry I didn't read your first mentioning of it close enough. I never even thought that would make a difference. So sorry.

                    Yes, those conditions were overly complicated. They didn't start that way, but when things weren't working, I started trying everything to see what would work

                    All the data is Date AND Time. My screenshot just shows a date, but that's because I wanted the info more concise.
                    Brad Steinfeldt

                    Comment


                      #11
                      Re: Logical value for a date field

                      Glad it worked out. Alpha is very unforgiving and confusing in areas like this. You never know what they're actually doing in their code. It's only by experience you learn their quirks.

                      Comment

                      Working...
                      X