Welcome to SPN

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

Sign Up Now!
  1. Guest ji, please consider donating today!
      Become a Supporter    ::   Make a Contribution   
    Monthly Recurring Target: $300 :: Achieved: $95

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]
    >
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page