I have strings like FVS101209GO5 Stored in a MS Access data table, I want to count the number of strings in a certain year, so in the example that would be the year 2010
I was doing
query = "SELECT SUM( IIF( Mid( KEYLastName, 4, 2) , 1,0)) AS occur FROM MyTable WHERE Year(mydate)=2010 ;"
The length of the string is 12 or 13, for the examples @JW added
qwe123456XXX - 2012
asd345678XXX - 2034
FVS101209GO5 - 2010
If you wish to find the count of occurrences of various years within a string, you might like to use:
This will return all the two digit years at (4,2) and the number of times they each occur.
Edit re Comments