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

character to date field conversion

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

    character to date field conversion

    I have some character fields that are in this format 20100612 and I need to change them to date field...how do i do this?
    i wasn't able to find it in help or the message boards.
    If I just change it in the table restructure, data gets lost.
    Please help someone. :)

    #2
    Re: character to date field conversion

    Where and how did you look in the help? It is definitely in there.
    Tim Kiebert
    Eagle Creek Citrus
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

    Comment


      #3
      Re: character to date field conversion

      Have you discovered the date and time functions in the help system? The STOD() function seems promising.

      Comment


        #4
        Re: character to date field conversion

        Thanks Tom, perfect. I was looking for date conversion and for some reason it wasn't coming up.

        Comment


          #5
          Re: character to date field conversion

          Ok...here is a super newbie stupid question....where do I write this function to get this to work. Do I create a new date field and then there?

          Comment


            #6
            Re: character to date field conversion

            Time to get acquainted with the user's guide. The chapter on Batch Operations has a section on "Update Operations". You can solve your problem by adding a date type field to your table and then defining an Update Operation that populates it from the current character field, using the stod() function.

            Batch operations can create havoc in the hands of beginners and experienced veterans alike. My personal rule is to make two separate, good, backups, before running untested operations.

            In fact, it's often simplest to work with a copy of the database instead of the live (actual) data while doing your design.

            Comment


              #7
              Re: character to date field conversion

              Yeah I tried that. I went to operations, update, then selected my date field (which is not char), then I typed in:
              stod() and it tells me invalid or incomplete expression.
              I'm doing something wrong.

              Comment


                #8
                Re: character to date field conversion

                I found out the hard way re: backups....you are totally right!!!

                Comment


                  #9
                  Re: character to date field conversion

                  Ok, since you say you have c++ and vb experience we are not going to cut you as much slack. :) Just kidding.

                  STOD() takes a character parameter in the form of "YYYYMMDD" which you have in your original field.
                  So you should have something like stod(FieldName).
                  Replace 'Fieldname' with the name of the field that has the character data.
                  Tim Kiebert
                  Eagle Creek Citrus
                  A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                  Comment


                    #10
                    Re: character to date field conversion

                    Ok, I go to update operation, choose my table, then go to create operation, choose date field, in expression, I type STOD(char_field).
                    I get an error message that says expression does not evaluate to a date value.
                    What am I doing wrong?

                    Comment


                      #11
                      Re: character to date field conversion

                      Can you supply a sample of your app?

                      Is char_field the name of your field?
                      What is the size of that field? If it is larger than 8 try stod(alltrim(char_field))
                      Is the data in the form of YYYYMMDD

                      You will need to make sure that each entry is exactly of that form.
                      Tim Kiebert
                      Eagle Creek Citrus
                      A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                      Comment


                        #12
                        Re: character to date field conversion

                        Yes, char_field is the name of my field. The date and char field are the same size.
                        Here is the code. it will run the operation without error messages but date is not changed in the date field, it's jsut empty.

                        'Operation is based on current filter and order of current table.
                        'Get the current table's filter and order expression

                        dim mru as p
                        mru = mru_query("il")
                        current_filter = mru.filter
                        current_order = mru.order
                        current_flags = mru.flags

                        'Check to see if current filter/order is valid in the context of "il"
                        if current_filter <> "" then
                        if eval_valid(current_filter,"il") =.f. then
                        a5_Operation_Warning() 'Display warning if current selection is meaningless
                        current_filter = ".t."
                        end if
                        end if

                        if current_order <> "" then
                        if eval_valid(current_order,"il") = .f. then
                        current_order = ""
                        end if
                        end if

                        a_tbl = table.open("il")
                        ON ERROR GOTO ERROR1306201000105403


                        DIM a5_operation_filter as C
                        a5_operation_filter = current_filter
                        query.filter = a5_operation_filter
                        DIM a5_operation_order as C
                        a5_operation_order = current_order
                        query.order = a5_operation_order
                        query.options = "I"+current_flags
                        query.description = "Temporary Query"
                        a_tbl.query_create("N")

                        update.fields = 2
                        update.field1 = "LIC_ISSUED"
                        update.expr1 = "CTOD(LIC_F_ISS)"
                        update.field2 = "LIC_EXP_DATE"
                        update.expr2 = "CTOD(LIC_EXP)"

                        a_tbl.update()


                        GOTO CONTINUE1306201000105403
                        ERROR1306201000105403:
                        ON ERROR GOTO 0
                        ui_msg_box("Error","Error running Update Operation"+crlf()+error_text_get())
                        END
                        CONTINUE1306201000105403:
                        a_tbl.close()'If the Operation is run from within a Form or Browse, then refresh the window
                        if is_object(topparent.this) then
                        if topparent.Class() = "form" .or. topparent.class() = "browse" then
                        topparent.Refresh_layout()
                        end if
                        end if

                        Comment


                          #13
                          Re: character to date field conversion

                          sorry, I meant to say my character field is a character. The names are in the code.

                          Comment


                            #14
                            Re: character to date field conversion

                            In looking at this code, how does it know to takenad populate the date fields, it will cahnge them but there is no command to populate it...is that what CTOD does? it changes it and then it populates it too?

                            Comment


                              #15
                              Re: character to date field conversion

                              Originally posted by FreeBird View Post
                              In looking at this code, how does it know to takenad populate the date fields, it will cahnge them but there is no command to populate it...is that what CTOD does? it changes it and then it populates it too?
                              No. It is the inner workings of the update operation. It takes the result of update.expr1 and assigns it to the field specified in update.field1.


                              I am a bit confused as I thought we were using STOD().
                              Last edited by Tim Kiebert; 06-13-2010, 12:39 AM.
                              Tim Kiebert
                              Eagle Creek Citrus
                              A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                              Comment

                              Working...
                              X