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

Get date into Args?

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

    Get date into Args?

    Hi Guys,

    I am using the following code to open a dialog to get two dates.

    Code:
    DIM SHARED vd_first_date as D
    DIM SHARED vd_last_date as D
    DIM SHARED varC_result as C
    ok_button_label = "&OK"
    cancel_button_label = "&Cancel"
    varC_result = ui_dlg_box("Date Range Selector",<<%dlg%
    {region}
    Start Date:| [%DATE;P=popup.calendar(dtoc(vd_first_date));I=popup.calendar%.40vd_first_date!vd_first_date_*];
    Last Date:| [%DATE;P=popup.calendar(dtoc(vd_last_date));I=popup.calendar%.40vd_last_date!vd_last_date_*];
    {endregion};
    {line=1,0};
    {region}
    <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
    {endregion};
    %dlg%,<<%code%
    if left(a_dlg_button,14) = "vd_first_date_" then 
    	if a_dlg_button = "vd_first_date_killfocus" then 
    		vd_first_date = ctod(dtoc(vd_first_date))
    	end if 
    	a_dlg_button = ""
    end if 
    
    if left(a_dlg_button,13) = "vd_last_date_" then 
    	if a_dlg_button = "vd_last_date_killfocus" then 
    		vd_last_date = ctod(dtoc(vd_last_date))
    	end if 
    	a_dlg_button = ""
    end if
    %code%)
    I need to use the dates as values to filter an SQL table in a date range. How do I convert the Xbasic Dates to SQL syntax?

    It seems the SQL must be without double quotes, which is what you get when converting with DTOC(vd_first_date,"1/")

    Is there a function to substitute the double quotes for single quotes?

    eg WHERE APPLICATION_DATE BETWEEN :vd_first_date AND :vd_last_date
    Last edited by Keith Hubert; 07-30-2013, 11:38 AM.
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

    #2
    Re: Get date into Agrs?

    I think this is posted in the wrong forum, but I know I'm able to set dates to date_format(date(),"yyyy-MM-dd") or time("yyyy-MM-dd",date()) and set the argument to that.

    Comment


      #3
      Re: Get date into Agrs?

      Hi Chris,

      Thanks for you suggestion.

      In interactive I get:
      x=date_format(date(),"yyyy-MM-dd")
      ?x
      = {30/07/2013}

      SQL does not like the curly brackets, any suggestions how to end up with '30/07/2013' ?
      Regards
      Keith Hubert
      Alpha Guild Member
      London.
      KHDB Management Systems
      Skype = keith.hubert


      For your day-to-day Needs, you Need an Alpha Database!

      Comment


        #4
        Re: Get date into Agrs?

        I don't know how you're ending up with that, but x is going to be a character string, that the args.set("arg1",x) then takes care of.

        Comment


          #5
          Re: Get date into Agrs?

          Originally posted by Keith Hubert View Post
          Hi Chris,

          Thanks for you suggestion.

          In interactive I get:
          x=date_format(date(),"yyyy-MM-dd")
          ?x
          = {30/07/2013}

          SQL does not like the curly brackets, any suggestions how to end up with '30/07/2013' ?
          Try that again, Keith. I get

          x=date_format(date(),"yyyy-MM-dd")
          ? x
          = "2013-07-30"

          You might want to begin with

          delete x
          dim x as C
          x=date_format(date(),"yyyy-MM-dd")
          ? x
          = "2013-07-30"

          From your original request it looks like you really want

          x=date_format(date(),"dd/MM/yyyy")

          Footnote/Warning: Due to Alpha's automatic type conversion you can

          delete x
          dim x as D
          x=date_format(date(),"yyyy-MM-dd")
          ? x
          = {07/30/2013}

          with the result that Alpha converts the character result of date_format() "invisibly".
          Last edited by Stan Mathews; 07-30-2013, 02:21 PM.
          There can be only one.

          Comment


            #6
            Re: Get date into Args?

            Time works nice and easy.
            Code:
            ? time("yyyy-MM-dd",date())
            = "2013-07-30"
            ? time("yyyy-MM-dd",now())
            = "2013-07-30"
            
            ? time("yyyy-MM-dd",{12/31/2012})
            = "2012-12-31"
            Gregg
            https://paiza.io is a great site to test and share sql code

            Comment


              #7
              Re: Get date into Args?

              Hi Guys,

              Thanks for your input.

              My problem is not getting the date format mm/dd/yyyy, but getting it into a format that can be used as part of the filter in a SQL WHERE statement uses ARGS.

              Maybe I'm missing something here about setting an ARG variable with a date.
              Regards
              Keith Hubert
              Alpha Guild Member
              London.
              KHDB Management Systems
              Skype = keith.hubert


              For your day-to-day Needs, you Need an Alpha Database!

              Comment


                #8
                Re: Get date into Args?

                Hi Keith

                Try

                args.set("vd_first_date",convert_type("vd_first_date","D"))

                Make sure you have declared args
                Glen Schild



                My Blog

                Comment


                  #9
                  Re: Get date into Args?

                  The SQL_DATE() function generates a character string with the format: {YYYY-MM-DD}.

                  Supported By

                  Alpha Five Version 8 and Above

                  Example

                  ? sql_date(date() )
                  = "{2006-03-22}"? sql_date(date() )
                  = "{2006-03-22}"
                  Gregg
                  https://paiza.io is a great site to test and share sql code

                  Comment


                    #10
                    Re: Get date into Args?

                    Hi Guys,

                    Many thanks for all you help.

                    My mistake was trying to work from what my customer had already started instead of using the built in Alpha SQL genie.

                    Using the SQL Genie in AS did the trick.
                    Regards
                    Keith Hubert
                    Alpha Guild Member
                    London.
                    KHDB Management Systems
                    Skype = keith.hubert


                    For your day-to-day Needs, you Need an Alpha Database!

                    Comment


                      #11
                      Re: Get date into Args?

                      Gregg, don't know how I'd missed that but thanks for the help. That's a great function to have. I am curious if anyone knows what the second option does. The first option changes from date type to character but I don't see any difference in the second option....
                      Code:
                      ?sql_date(date(),1)
                      = "{2013-07-31}"
                      ?sql_date(date(),2)
                      = "2013-07-31"
                      
                      ?sql_date(now(),1)
                      = "{2013-07-31 10:39:47.939}"
                      ?sql_date(now(),2)
                      = "2013-07-31 10:39:56 104000"

                      Comment


                        #12
                        Re: Get date into Args?

                        I think it corresponds to MS SQL datetime and datetime2 formats.

                        datetime2 has 100 nanosecond accuracy.

                        Comment


                          #13
                          Re: Get date into Args?

                          I tried using the sql_date() function.
                          Unfortunately, it includes the {}.
                          I went back to the time() function, which formats the date correctly.
                          Gregg
                          https://paiza.io is a great site to test and share sql code

                          Comment


                            #14
                            Re: Get date into Args?

                            If you just want the date portion, see this above:

                            ?sql_date(date(),1)
                            = "{2013-07-31}"
                            ?sql_date(date(),2)
                            = "2013-07-31"

                            That said, I tried using it on a time yesterday and couldn't seem to make it MySQL-happy, so I'm still trying it out.

                            Comment


                              #15
                              Re: Get date into Args?

                              Part of why I like the time() function much better.

                              ? time("yyyy-MM-dd 0h:0m:0s",now())
                              = "2013-08-03 11:40:39"
                              Gregg
                              https://paiza.io is a great site to test and share sql code

                              Comment

                              Working...
                              X