473,503 Members | 1,685 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Left and SQL

76 New Member
Stupid question I'm sure.....

Field entryType has values of ##/y and ###/y.

In a simple Access SQL I'd like to trim, from the right up to the "#".
I don't need/want the "/y"

Thanks!
Jan 13 '10 #1
10 1701
MMcCarthy
14,534 Recognized Expert Moderator MVP
try ...
Expand|Select|Wrap|Line Numbers
  1. left(len([fieldname])-2)
  2.  
Jan 13 '10 #2
artemetis
76 New Member
Thanks!
I tried this and received an #Error?
Jan 13 '10 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
OK change the query view to SQL and post the full query here.
Jan 13 '10 #4
nico5038
3,080 Recognized Expert Specialist
Guess you worded your question a bit vague.
I think you want to get the ## or ### and ignore the /y
Then use:
Expand|Select|Wrap|Line Numbers
  1. left([fieldname],instr([fieldname],"/")-1)
  2.  
When the "/y" is a literal you could also use:
Expand|Select|Wrap|Line Numbers
  1. Replace([fieldname],"/y","")
  2.  
Nic;o)
Jan 13 '10 #5
artemetis
76 New Member
Thanks Guys!

Nico', that worked perfectly!!! Sorry my initial question wasn't quite clear.

To take it one step further....there are several records that are missing data in the field. For these records, the query returns the #Error code. Is there a way (IIF?) I could display a 0 rather than the err?

I'm trying to get this on my own using IIF, not sure if this is the right route.....
Jan 13 '10 #6
MMcCarthy
14,534 Recognized Expert Moderator MVP
There are a couple of ways you could do this but try ...
Expand|Select|Wrap|Line Numbers
  1. IIf(NZ([fieldname],"")<>"",left([fieldname],instr([fieldname],"/")-1),"")
  2.  
Jan 13 '10 #7
nico5038
3,080 Recognized Expert Specialist
Good sample Mary, but it can be done a bit shorter:
Expand|Select|Wrap|Line Numbers
  1. IIf(IsNull([fieldname],"",left([fieldname],instr([fieldname],"/")-1))
  2. ' or better when also empty fields or fields without a "/" exist:
  3. IIF(Instr(NZ([fieldname),"/")>0,left([fieldname],instr([fieldname],"/")-1),"")
  4.  
I would use the second proposal as that's really 100% "safe".

Nic;o)
Jan 13 '10 #8
MMcCarthy
14,534 Recognized Expert Moderator MVP
I like the second one too :D

It allows for all eventualities.
Jan 13 '10 #9
artemetis
76 New Member
I used Msquared's code - it worked fine!

I'm using this IIF in an Append Query.
Is it possible, to insert/display a 0 when the field is blank?
Jan 14 '10 #10
MMcCarthy
14,534 Recognized Expert Moderator MVP
Just change the last set of empty double quotes in the IIf statement to 0.
Jan 14 '10 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

7
8398
by: Wayne Wengert | last post by:
I use statements like LEFT(textstring,6) in my app. I have "Imports Microsoft.VisualBasic" at the top of the code but to use LEFT I have to code : Microsoft.VisualBasic.Left(sting, integer) If...
4
8384
by: Harlan Messinger | last post by:
What is *supposed* to be the way to specify the horizontal offset of (a) the list item's marker and (b) the list item's content? In particular, see ...
4
4089
by: jbm05 | last post by:
Hi, I'm curious about the computational complexity of a query I have. The query contains multiple nested self left joins, starting with a simple select, then doing a self left join with the...
1
2300
by: fleemo17 | last post by:
For increased accessibility, I've replaced "display:none" with the Off-Left method of hiding my CSS drop-down menus because the Jaws screen reader doesn't see any of the menus hidden with...
17
760
by: Nathan Given | last post by:
Hello All, I am trying to debug a broken query. The query uses Left$(,4) instead of Left(,4). What is the difference between the Left() and Left$() functions in Microsoft Access? Thanks!...
0
2036
by: jonipony | last post by:
HELP: Float Left box is drifting to the right in ie! -------------------------- I need som HELP with my CSS coding! On the following web page my design falls apart at screen size 800 x 600...
8
2358
by: marco | last post by:
Hi ! I have this part of code and i can not find out why the scroller is starting from left to right instead RIGHT to LEFT. This is the main part and the scroller is working fine but from the...
6
1999
by: Samuel Rhodes | last post by:
Hi I am trying to write a code snippet that would display a '?' sign on the top left of a control. I do not want to hard code the positioning of the DIV which will contain that '?'. Is it...
6
6741
by: =?Utf-8?B?R3JlZw==?= | last post by:
I have two questions with regards to the LEFT function. I ran into a problem with the LEFT function today. I knew it was a valid Function, but when I tried to use it, it was getting interpreted...
4
10076
by: moondaddy | last post by:
I have a wpf project where I use a canvas to drag shapes around. when I drag a shape beyond the right or bottom side I get scrollbars which is good. I also get scrollbars when I zoom in and a...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7460
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.