Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hii all

how could i select the middle two characters on a string ?

i.e if i have astring like '20090305' i'd like to return only '03'

i used access datasource in my project
Posted
Updated 30-Jun-18 6:15am
v2

Use the SubString[^] method :)

--edit
The same method exists in Access, it's called the Mid function there. Enjoy your Googling :)
 
Share this answer
 
v3
Use a substring function:

SELECT SUBSTRING('20090305', 5, 2)
 
Share this answer
 
TWo things

1 - please don't push 'answer' to ask more questions. Answer and question are opposites, not the same. Edit your post

2 - tag your question correctly. Your tag says SQL-Server, so you got the right answer for SQL-Server. You should have tagged it Access if you're using Access
 
Share this answer
 
sorry but how this could be done in Access

i used access data source and when i use substring function i get the error : Undefined function [SUBSTRING]
 
Share this answer
 
i found the solution somewhere

the fuction that replace substring in Access is MID

i.e : MID(string , startIndex , NoOfChar )

hope this helps

Regards
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900