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

Convert ux date control value to sql date format

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

    Convert ux date control value to sql date format

    I am wondering if I am missing something because I can't believe that it is this cumbersome to convert a ux date control into a format that can be used in a sql update method in an ajax callback.

    What I have had to do in the ajaxcallback.

    get the value of the date control.
    convert it to a date with the ctod() function.
    convert it to a slq date with the sql_date() function, which returns a character value like {2015-06-10}.
    lastly I have to remove the curly brackets.
    then it can be used in the sql update method.

    Does that seem reasonable or am i just getting lazy?
    Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

    #2
    Re: Convert ux date control value to sql date format

    why do you need all of those, when the (ux) dialog is bound to that table, alpha is supposed to do that for you, is that not correct?
    even if you were to update another unrelated table like log then still alpha can update, without those translation, am i not correct?
    thanks for reading

    gandhi

    version 11 3381 - 4096
    mysql backend
    http://www.alphawebprogramming.blogspot.com
    [email protected]
    Skype:[email protected]
    1 914 924 5171

    Comment


      #3
      Re: Convert ux date control value to sql date format

      This ux is just a little app that I have created to set the report options for my invoices. I do not have it bound to a table. I am just using some controls and setting some report options, saving it to disk and viewing it, etc and I need to update a couple of fields in the table. I made this ux way back when they were new and I did not know much about them.

      As I am typing this I am thinking that maybe I should just bind it to the table after all.
      Thanks for pointing out the obvious, I will give it a try.
      Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

      Comment


        #4
        Re: Convert ux date control value to sql date format

        Here's what I do

        if e.dataSubmitted.CORRECTION_DATE != "" then
        vTempD = convert_type(e.dataSubmitted.CORRECTION_DATE,"D")
        vTempC = dtoc(vTempD,"12-")
        vSQLtxt = vSQLtxt + "CORRECTION_DATE = '"+vTempC+"', "
        end if

        Pat
        Pat Bremkamp
        MindKicks Consulting

        Comment


          #5
          Re: Convert ux date control value to sql date format

          Thanks for the idea Pat.
          This simplified it for me a little but I still think I am going to bind the ux to a table.
          cSqlDate = substr(sql_date(ctod(e._currentRowDataNew.IDATE)),2,10)
          Last edited by frankbicknell; 06-10-2015, 09:01 PM.
          Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

          Comment


            #6
            Re: Convert ux date control value to sql date format

            i am still wondering. if you just assign the argument to the e.dataSubmitted.IDATE without converting
            does it not update the sql table properly?
            (or you need this conversion for your filter for the report?)
            thanks for reading

            gandhi

            version 11 3381 - 4096
            mysql backend
            http://www.alphawebprogramming.blogspot.com
            [email protected]
            Skype:[email protected]
            1 914 924 5171

            Comment


              #7
              Re: Convert ux date control value to sql date format

              Without the conversion I get a mySql error stating that the date is in the wrong format. Surprised me too. I am using a ux control set up as a date.
              Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

              Comment


                #8
                Re: Convert ux date control value to sql date format

                i did a test using mysql just like you have and i had no problem.
                the table and dialog are not bound together, the i used insert function ( will be no difference for update ) using ajax callback.
                did you use arguments?
                thanks for reading

                gandhi

                version 11 3381 - 4096
                mysql backend
                http://www.alphawebprogramming.blogspot.com
                [email protected]
                Skype:[email protected]
                1 914 924 5171

                Comment


                  #9
                  Re: Convert ux date control value to sql date format

                  Code:
                  if result then
                  		sqlInsert = "INSERT INTO frank1 (name, date) values (:newName, :newDate)"
                  		args.set("newName", name)
                  		args.set("newDate", date1)
                  		result = cn.Execute(sqlInsert,args)
                  		if result then
                  			xb = "alert('success')";
                  		end if
                  http://screencast.com/t/cvmzMvMj0Mx

                  code and result
                  thanks for reading

                  gandhi

                  version 11 3381 - 4096
                  mysql backend
                  http://www.alphawebprogramming.blogspot.com
                  [email protected]
                  Skype:[email protected]
                  1 914 924 5171

                  Comment


                    #10
                    Re: Convert ux date control value to sql date format

                    If I use the value without converting I get the error from mysql.

                    this is the update statement.

                    Code:
                    				myargs.set("maIdate",cSqlDate)
                    					cErrorMsgNo = "101"
                    					
                    					
                    					OK = cn.open("::Name::connection_string")
                    					if OK
                    						sqlStatement = <<%sql%
                    						update table set idate = :maIdate, hard_copy = :maInvFileName where id= :maInvID %sql%
                    						OK = cn.execute(sqlStatement,myargs)
                    					end if
                    Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

                    Comment


                      #11
                      Re: Convert ux date control value to sql date format

                      Code:
                      dim name as c
                      	dim date1 as d
                      	name = e.dataSubmitted.name
                      	date1 = e.dataSubmitted.date
                      	
                      	dim cn as sql::Connection
                      	dim args as sql::Arguments
                      	dim result as l
                      	dim sqlInsert as c
                      	
                      	result = cn.Open("::Name::local_mySql")
                      	if result then
                      		sqlInsert = "INSERT INTO frank1 (name, date) values (:newName, :newDate)"
                      		args.set("newName", name)
                      		args.set("newDate", date1)
                      		result = cn.Execute(sqlInsert,args)
                      		if result then
                      			xb = "alert('success')";
                      		end if
                      		cn.close()
                      	end if
                      i did not convert to a sql date just as it came from the dialog.
                      thanks for reading

                      gandhi

                      version 11 3381 - 4096
                      mysql backend
                      http://www.alphawebprogramming.blogspot.com
                      [email protected]
                      Skype:[email protected]
                      1 914 924 5171

                      Comment


                        #12
                        Re: Convert ux date control value to sql date format

                        i just did an update works without any problem. do not convert the date just use it as it comes.
                        thanks for reading

                        gandhi

                        version 11 3381 - 4096
                        mysql backend
                        http://www.alphawebprogramming.blogspot.com
                        [email protected]
                        Skype:[email protected]
                        1 914 924 5171

                        Comment


                          #13
                          Re: Convert ux date control value to sql date format

                          Thank you for your help Govindan I am going to have to figure out why this is not working for me. It did seem like a lot of work to have to convert a date in a ux for sql.
                          Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

                          Comment


                            #14
                            Re: Convert ux date control value to sql date format

                            you know what the format is - just use a function and then submit it.
                            function timestampAdd as c (e as p)
                            debug(1)
                            dim ts as c
                            ts = time("yyyy-MM-dd 0h:0m:0s", now())
                            e._set.Person_AddedOn.value = ts
                            end function
                            Cheers Pete.
                            Insanity: doing the same thing over and over again and expecting different results.
                            Albert Einstein, (attributed)
                            US (German-born) physicist (1879 - 1955)

                            Comment


                              #15
                              Re: Convert ux date control value to sql date format

                              Originally posted by frankbicknell View Post
                              Thank you for your help Govindan I am going to have to figure out why this is not working for me. It did seem like a lot of work to have to convert a date in a ux for sql.
                              what is the data type in MySQL table, and what is the data type in the ux and what is the data entered on data entry.
                              if they are all the same then there should be no problem.
                              thanks for reading

                              gandhi

                              version 11 3381 - 4096
                              mysql backend
                              http://www.alphawebprogramming.blogspot.com
                              [email protected]
                              Skype:[email protected]
                              1 914 924 5171

                              Comment

                              Working...
                              X