Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Zero-fill existing data

Discussion in 'Information Technology' started by JimMurray, Jul 28, 2006.

  1. JimMurray

    JimMurray
    Expand Collapse
    Guest

    I'm transfering data from an old database that didn't use input masks. The
    proper form for one field would be 00-00-0000. I've brought most data up to
    00-00-???? but the last four characters have been input as 0 , 00 , 000 , or
    0000. I need to zero fill the last four for search capability.
    Please help.
     
  2. Loading...

    Similar Threads Forum Date
    Legal Lok Pal Bill - Difference of Existing System & System proposed by Civil Society Breaking News Aug 20, 2011
    Non Existing 'I' Gurmat Vichaar Feb 19, 2008
    Sikh News Punjab govt to add 300 new buses to existing fleet (New Kerala) Breaking News Jun 29, 2007

  3. John Vinson

    John Vinson
    Expand Collapse
    Guest

    On Mon, 3 Jul 2006 09:57:02 -0700, JimMurray
    <JimMurray@discussions.microsoft.com> wrote:

    >I'm transfering data from an old database that didn't use input masks. The
    >proper form for one field would be 00-00-0000. I've brought most data up to
    >00-00-???? but the last four characters have been input as 0 , 00 , 000 , or
    > 0000. I need to zero fill the last four for search capability.
    >Please help.


    An Update query updating the appropriate records (I don't know your
    data so I don't know what criteria would be used!) to

    Left([textfield] & "0000", 10)

    will tack on enough zeros to bring the length of the field up to 10
    bytes. Adapt as appropriate...

    John W. Vinson[MVP]
     
  4. JimMurray

    JimMurray
    Expand Collapse
    Guest

    I'm not being clear about the problem. The data is

    01-05-12
    01-05-123
    01-05-1
    01-05-1234

    where 01- is the first month of the year,
    05- is the year
    and the final four the id number.

    I want to enter a zero fill to allow a text search of the field.


    01-05-0012
    01-05-0123
    01-05-0001
    01-05-1234
    I have 30.000 records to change.

    Thanks, Jim

    "John Vinson" wrote:

    > On Mon, 3 Jul 2006 09:57:02 -0700, JimMurray
    > <JimMurray@discussions.microsoft.com> wrote:
    >
    > >I'm transfering data from an old database that didn't use input masks. The
    > >proper form for one field would be 00-00-0000. I've brought most data up to
    > >00-00-???? but the last four characters have been input as 0 , 00 , 000 , or
    > > 0000. I need to zero fill the last four for search capability.
    > >Please help.

    >
    > An Update query updating the appropriate records (I don't know your
    > data so I don't know what criteria would be used!) to
    >
    > Left([textfield] & "0000", 10)
    >
    > will tack on enough zeros to bring the length of the field up to 10
    > bytes. Adapt as appropriate...
    >
    > John W. Vinson[MVP]
    >
     
  5. John Vinson

    John Vinson
    Expand Collapse
    Guest

    On Mon, 3 Jul 2006 11:46:01 -0700, JimMurray
    <JimMurray@discussions.microsoft.com> wrote:

    >I'm not being clear about the problem. The data is
    >
    >01-05-12
    >01-05-123
    >01-05-1
    >01-05-1234
    >
    >where 01- is the first month of the year,
    >05- is the year
    >and the final four the id number.
    >
    >I want to enter a zero fill to allow a text search of the field.
    >
    >
    >01-05-0012
    >01-05-0123
    >01-05-0001
    >01-05-1234
    >I have 30.000 records to change.


    It's text, and the hyphens are actually stored in the field?

    If so, and if you have AccessXP or later, update to

    Left([fieldname], 6) & Format(Val(Mid([fieldname],
    InStrRev([fieldname], "-") + 1)), "0000")

    BACK UP YOUR DATABASE first of course...!

    John W. Vinson[MVP]
     
  6. JimMurray

    JimMurray
    Expand Collapse
    Guest

    The solution works great.

    Thanks. Jim

    "John Vinson" wrote:

    > On Mon, 3 Jul 2006 11:46:01 -0700, JimMurray
    > <JimMurray@discussions.microsoft.com> wrote:
    >
    > >I'm not being clear about the problem. The data is
    > >
    > >01-05-12
    > >01-05-123
    > >01-05-1
    > >01-05-1234
    > >
    > >where 01- is the first month of the year,
    > >05- is the year
    > >and the final four the id number.
    > >
    > >I want to enter a zero fill to allow a text search of the field.
    > >
    > >
    > >01-05-0012
    > >01-05-0123
    > >01-05-0001
    > >01-05-1234
    > >I have 30.000 records to change.

    >
    > It's text, and the hyphens are actually stored in the field?
    >
    > If so, and if you have AccessXP or later, update to
    >
    > Left([fieldname], 6) & Format(Val(Mid([fieldname],
    > InStrRev([fieldname], "-") + 1)), "0000")
    >
    > BACK UP YOUR DATABASE first of course...!
    >
    > John W. Vinson[MVP]
    >
     

Share This Page