Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Substring
Message
From
14/08/2012 07:31:03
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Substring
Miscellaneous
Thread ID:
01550460
Message ID:
01550460
Views:
78
What am i doing wrong here

scanfilename = 'TB20111031GADO11FTB220181z220182.tif'

select scanfilename,CHARINDEX('O11FTB',scanfilename)+6 as pos_start,
CHARINDEX('tif',scanfilename) as pos_end,
(CHARINDEX('tif',scanfilename)-CHARINDEX('O11FTB',scanfilename)) as diff
from scans where scanfilename like '%O11FTB%'

produces

scanfilename pos_start pos_end diff
TB20111031GADO11FTB220181z220182.tif 20 34 20

why am I not getting 34 - 20 so answer 14

Thanks
Next
Reply
Map
View

Click here to load this message in the networking platform