Results 1 to 2 of 2

Thread: format right number in field

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,943

    format right number in field

    I just have a jet ado conn opned.
    my db is access
    my table is named Mytable
    Into field CODE have a value similar:

    0500-1
    6875-45
    ...

    How to update, with a sql query to format the right item from "-" in #000000 for all value in column field.
    and have a result similar

    0500-000001
    6875-000045
    ...

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: format right number in field

    The following sql will work with MS Access; kim that you may need some additional conditions iin the where clause:
    update table1
    set field2 = left$(field2, instr(1,field2,"-")) + format$(mid$(field2, instr(1,field2,"-")+1), "000000")
    where field2 is not null
    and instr(1,field2,"-") > 0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width