Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    samdahlr is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2014
    Posts
    28

    Eliminating last 3 characters of data from each value of an entire column of values

    Hello,



    I have an entire column of values ending in ".00". For example 123456.00. I want to get rid of the last 3 characters, the ".00" from each value for the entire column. I preferably want to do this in SQL language.

    Any thoughts?

    Thank you

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    I believe you can do this with an Update Query, using Mid() and Len() functions in an expression that returns the required values.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    samdahlr is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2014
    Posts
    28
    I am very new to access. The table name is "CAMS" and the column name is "CAMS_ID". If you have the time, could you write an example SQL statement for me please?

    Thank you

  4. #4
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    Using RIGHT(FIELDNAME, 3) will show the last 3 character.
    Combined with REPLACE().

    It can be done in a update query or select to view.
    What Bob Fitz says will work as well.

  5. #5
    AnandKhinvasara is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2014
    Posts
    31
    Select round(cams_id,0) from cams

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Quote Originally Posted by samdahlr View Post
    I am very new to access. The table name is "CAMS" and the column name is "CAMS_ID". If you have the time, could you write an example SQL statement for me please?

    Thank you
    Make a backup of your data
    then try this:
    Code:
    UPDATE CAMS SET CAMS.CAMS_ID = Mid([CAMS_ID],1,(Len([CAMS_ID])-3));
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    It is unlikely your field has the ".00" actually stored. It is more likely to be a display format setting.

  8. #8
    samdahlr is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2014
    Posts
    28
    I just need to get rid of the ".00" for the time being so I can combine it with other data in Access that is in 123456 format not 123456.00.

    I tried this,

    select CAMSID
    from CAMS
    RIGHT (CAMSID, 3)
    REPLACE ()
    ;

    It is saying I have a syntax error in JOIN operation.

  9. #9
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    If it is a Numeric field then the query will let you set the output format of the field. I would suggest "General" format.

  10. #10
    samdahlr is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2014
    Posts
    28
    I am not seeing an option to set the output format anywhere. I tried using this and it still says syntax error.

    Update CAMS
    set CAMSID
    where RIGHT (CAMSID, 3)
    REPLACE ()
    ;

  11. #11
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Have you tried my suggestion in post #6
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  12. #12
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    What is the data type of the CAMS_ID field in the table? An ID field should be numeric-long or numeric-integer.

    Are you trying to actually change data in the table, or only how you see it in a query? To change the display format in a query (for a numeric column), in design view, right-click in the column; from the dropdown select Properties. In the property sheet, set the "Format" to "General Number", and "Decimal Places" to 0.

    When you run the query, that column will show the numbers with no decimal places.

    John

  13. #13
    samdahlr is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2014
    Posts
    28
    Bob, I tried your statement and it did not get rid of the .00 in the database. Yes, I actually want to change the data in the database to show 123456 instead of 123456.00. Essentially change the format not the actual person's ID. Will changing the properties in design view work for this?

  14. #14
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Can you answer the points raised by John in post #12
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  15. #15
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Yes, you can change the properties in the table. Set the data type of the CAMS_ID field to Numeric - Long.

    You will probably get a warning message about possibly losing some data, but that refers to the parts following the decimal point, which in your case are always 0 (I hope).

    Now, if you have a form or query that has the format set to show 2 decimal points, it is still going to do that, even though you changed the data type in the table. You will have to fix the display formats as well.

    John

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 07-17-2014, 09:16 AM
  2. Replies: 4
    Last Post: 04-22-2014, 08:23 AM
  3. Drop Down Box changes entire column
    By tennisbuck in forum Forms
    Replies: 4
    Last Post: 02-26-2014, 12:23 PM
  4. added text to entire column in the Query
    By Jerseynjphillypa in forum Queries
    Replies: 3
    Last Post: 06-12-2012, 09:39 AM
  5. Replies: 3
    Last Post: 04-01-2012, 01:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums