Filter column string with Right function?

I am trying to strip off the .jpg extension in my filenames... but the query I am using returns nothing.

How do I filter a column full of serialized photo file names with Right function?

I have a column full of filenames of serialized photos:
[FileName]
d3x_6013.jpg
d3x_6014.jpg
d3x_6015.jpg

I simply want to remove the .jpg extension using the Right function.

When I use the following formula in a query using the Right function in the criteria field it returns nothing?

Right([FileName],8)

(Ideally, I would like a query that would also strip out the "d3x" off the beginning of the filename as well, so I am left with just the numbers.)

-Greg
geekmee2Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
<.... into the criteria field in the query. > that is not correct

it should be like this


            field    [FileName]  |  val(mid([FileName],5))
table name                         |
criteria



x
0
 
Rey Obrero (Capricorn1)Commented:
try this query

select [FileName], val(mid([FileName],5))
from tablex


or this

select [FileName], mid([FileName],5,Instr([FileName],".")-5)
from tablex
0
 
Kelvin SparksCommented:
The right function returns the selected number of characters that you passed in , count in from the right. RIGHT([FileName],4) would give you .jpg

If the filename is always in the format you suggest, then LEFT([Filename],Len(Filename]-4) will give you what you want.


Kelvin
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
geekmee2Author Commented:
Left([Filename],"Len[Filename]-4") is giving me a "Data type mismatch" error?
0
 
Rey Obrero (Capricorn1)Commented:
@geekmee2

did you try the query I posted?
0
 
geekmee2Author Commented:
Yes, Capricorn.... It gave me an error of Invalid syntax or I needed to put quotes around text.
0
 
Rey Obrero (Capricorn1)Commented:
what do you mean?

how are you using what  I posted?
0
 
geekmee2Author Commented:
I copy and pasted.... into the criteria field in the query.
0
 
Rey Obrero (Capricorn1)Commented:
<I copy and pasted>  where did you paste ?

post what ever you have going.


<.... into the criteria field in the query. > that is not correct
0
 
Kelvin SparksCommented:
Left([Filename],"Len[Filename]-4") should be without the quotes

Kelvin
0
 
geekmee2Author Commented:
Invalid Syntax Error [see screenshot]
InvalidSyntax-Error.jpg
0
 
geekmee2Author Commented:
Kelvin, I tried, but the system adds the quotes (?).
0
 
Kelvin SparksCommented:
Ah should be
Left([Filename],Len([Filename])-4)

Kelvin
0
 
geekmee2Author Commented:
Capricorn1:  Yes, that worked!.... Thank you for the screenshot.

But please help me understand what this formula is doing?

Was I using the wrong function (Left) to accomplish this in the criteria field?
0
 
Rey Obrero (Capricorn1)Commented:
Left("d3x_6013.jpg",4) will give you  d3x_

Left("d3x_6013.jpg",Len("d3x_6013.jpg")-4)    > will give you  6013.jpg



Mid("d3x_6013.jpg",5) will give you 6013.jpg

Val(6013.jpg)  will give you  6013

so the combination  

val(Mid("d3x_6013.jpg",5) ) will give 6013


better look in the VBA help file  for the Left, Mid, Right function and the VAL function
0
 
geekmee2Author Commented:
Ok. so the the Mid function returns results to the Val function, and the Val function acts on what was passed to it, and gives me the final desired result.

So the Left function only gets me part of the way there, or my first request.

But still don't understand why the Left function in the criteria field was returning a blank set of results?
0
 
Rey Obrero (Capricorn1)Commented:
why a B grade ?
0
 
geekmee2Author Commented:
I did offer 500 points...for the answer, which you did give, promptly.

I still had questions, but you did offer extended breakdown of the other functions, and you did point me to additional resources, VBA helpfile.

I can change it to an A if you would like, I try and reserve A for exceptional effort.

As a trainer, I have feel the value of an answer is tailoring the answer to the knowledge level of the student... which I feel your screenshot accomplished.

How do go about revising the grade to an A?
0
 
geekmee2Author Commented:
I am happy to change it to an A if you like...

But in reviewing the posting, originally I was trying to use the Right function to achieve my goal.  You gave me another solution, which was better.

But for me, an A means there was no way to improve on the delivery of the answer.  
Here my gut reaction was "what am I doing wrong."   While the answer was correct, I was still left with the question of what I was doing wrong.

For me, an A would have helped me understand the flaw of my approach, which would have expanded my knowledge and understanding of using your (a better) approach.

Hope that helps.

-Greg
0
 
Kelvin SparksCommented:
Hmmmm,

This is a site for answers - not a training site, although many experts such as Capricorn1 so the extra mile and offers extra advice and reasoning. An A is usually given for a answer that fully solves the problem (whether or not training is provided).

Kelvin
0
 
geekmee2Author Commented:
Understood.... My bad.  I guess I need to manage my expectations.

I can change the grade to an A.... for it was very correct.
0
All Courses

From novice to tech pro — start learning today.