PC Review


Reply
 
 
Prav
Guest
Posts: n/a
 
      14th Aug 2008
Hi I have the following records in my table:-

PTR22334
AA0123
HDA/C001
'
E/Y001
FG
Z12345
000000123456
000078910112

How can my query return only 123456 & 78910112 only.
 
Reply With Quote
 
 
 
 
louisjohnphillips@gmail.com
Guest
Posts: n/a
 
      14th Aug 2008
On Aug 13, 6:08*pm, Prav <P...@discussions.microsoft.com> wrote:
> Hi I have the following records in my table:-
>
> PTR22334
> AA0123
> HDA/C001
> '
> E/Y001
> FG
> Z12345
> 000000123456
> 000078910112
>
> How can my query return only 123456 & 78910112 only.


Am I missing the point?

SELECT DesiredField
from MyTable
where left( DesiredField,1) = '0'

or

SELECT DesiredField
from MyTable
where left( DesiredField,4) = '0000'

If leading zeroes are to be eliminated

SELECT CInt( DesiredField )
from MyTable
where left( DesiredField,1) = '0'
 
Reply With Quote
 
 
 
 
Prav
Guest
Posts: n/a
 
      14th Aug 2008
Cheers

"(E-Mail Removed)" wrote:

> On Aug 13, 6:08 pm, Prav <P...@discussions.microsoft.com> wrote:
> > Hi I have the following records in my table:-
> >
> > PTR22334
> > AA0123
> > HDA/C001
> > '
> > E/Y001
> > FG
> > Z12345
> > 000000123456
> > 000078910112
> >
> > How can my query return only 123456 & 78910112 only.

>
> Am I missing the point?
>
> SELECT DesiredField
> from MyTable
> where left( DesiredField,1) = '0'
>
> or
>
> SELECT DesiredField
> from MyTable
> where left( DesiredField,4) = '0000'
>
> If leading zeroes are to be eliminated
>
> SELECT CInt( DesiredField )
> from MyTable
> where left( DesiredField,1) = '0'
>

 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      14th Aug 2008
On Wed, 13 Aug 2008 18:08:01 -0700, Prav <(E-Mail Removed)>
wrote:

>Hi I have the following records in my table:-
>
>PTR22334
>AA0123
>HDA/C001
>'
>E/Y001
>FG
>Z12345
>000000123456
>000078910112
>
>How can my query return only 123456 & 78910112 only.


As an alternative which doesn't depend on leading zeros, use a calculated
field

IsNumeric([fieldname])

with a criterion of True.

The only "gotcha" I can think of is that numbers in scientific notation such
as 3105E2 or 1154D28 will be seen as numeric.
--

John W. Vinson [MVP]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sumif number is greater than a number but less than another number lulu151 Microsoft Excel Misc 2 7th May 2010 07:12 PM
How to calculate number of occurencies of a specific number number Stefan Microsoft Excel Misc 4 8th Sep 2008 08:33 AM
replacing FIRST NUMBER-SECOND NUMBER with SECOND NUMBER Walter Microsoft Excel New Users 3 24th Feb 2008 04:26 PM
Re: number of spaces after number, period, number Suzanne S. Barnhill Microsoft Word Document Management 0 15th Dec 2006 05:03 AM
How do I set number formats that will be applied only if a number. =?Utf-8?B?SmltIEdlbnRpbGU=?= Microsoft Excel Misc 1 6th Oct 2004 04:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:53 PM.