Hi,
Would anyone now how to write an instr that would grab only the date from the string below (i.e between the 2 colons)
I have tried multiple times to get this to work to no avail, the colons will NOT always be at character 14, so need to find first ":" then grab the next 8 caracters.
USINAS SID MI:30/12/09:0.3072:85
i would like to achieve the result
30/12/09
so far I have tried using Left with instr and Right - getting very frustrated.
Thanks in advance
Nigel
8 1734 MMcCarthy 14,534
Recognized Expert Moderator MVP
Try this one ... -
Right(Left("USINAS SID MI:30/12/09:0.3072:85", InStr(1, "USINAS SID MI:30/12/09:0.3072:85", "/", vbTextCompare) + 5), 8)
-
Thanks msquared,
any chance I could put this in a query, dont really want to create a function but will do if it is the best way. I only need to perform this once a day on import for about 50 rows and was trying to just put an make table query on it.
Thanks
no worries - got it to work - just took the vbtextcompare out. Thanks for this saved me a lot of time
MMcCarthy 14,534
Recognized Expert Moderator MVP
You're welcome, glad you got it to work.
nico5038 3,080
Recognized Expert Specialist
An alternative might be a function: -
Function fncSplit(strInput As String)
-
Dim arr
-
arr = Split(strInput, ":")
-
fncSplit = arr(1)
-
End Function
-
In a query you can use: -
SELECT fncSplit([Field with colons]), ... FROM tblX
-
Nic;o)
Hi Guys,
Thanks you both for your answers, both work well, have a quick question, tried to do it myself but can this be modified to dismiss any fields that do not contain any ":" ? - at the moment it either returns the first 8 char with first option, or using the Function it will Error. I have tried writing an imbedded IF statement (i.e. IF(Instr[filed1],1=";", etc ) but cannot solve this. Appreciate the help Nic, Msquared.
Thanks
nico5038 3,080
Recognized Expert Specialist
Try -
Function fncSplit(strInput As String)
-
-
Dim arr
-
-
if Instr(strInput,":") > 0 then
-
arr = Split(strInput, ":")
-
fncSplit = arr(1)
-
else
-
'Empty string , or whatever you want to return
-
fncSplit = ""
-
end if
-
-
End Function
-
Nic;o)
Thanks Nic, should have known that myself - been staring at this far to long - going to take a break I think. Thanks again
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: hokieghal99 |
last post by:
import os, string
print " "
setpath = raw_input("Enter the path: ")
def find_replace(setpath):
for root, dirs, files in os.walk(setpath):
fname = files
for fname in files:
find =...
|
by: Jaime Wyant |
last post by:
Will someone explain this to me?
>>> "test".find("")
0
Why is the empty string found at position 0?
Thanks!
jw
|
by: Chris Mantoulidis |
last post by:
I posted this here one day ago but it seems like it hasn't been put up
for some unknown reason. That gives me a chance to say things a bit
better in this post.
1st of all let's desribe the...
|
by: Prakash Bande |
last post by:
Hi,
I have bool operator == (xx* obj, const string st). I have declared it
as friend of class xx. I am now able to do this:
xx ox;
string st;
if (&ox == st)
{
}
But, when I have a vector<xx*>...
|
by: Bryan Olson |
last post by:
The Python slice type has one method 'indices', and reportedly:
This method takes a single integer argument /length/ and
computes information about the extended slice that the slice
object would...
| |
by: KL |
last post by:
Hello again,
I am still working on this homework assignment and have hit a wall.
I have a list that I want to fill with all occurences of img tags from a
big string of html code. So I have a...
|
by: tehn.yit.chin |
last post by:
I am trying to experiment <algorithm>'s find to search for an item in a
vector of struct. My bit of test code is shown below.
#include <iostream>
#include <vector>
#include <algorithm>...
|
by: micklee74 |
last post by:
hi
say i have string like this
astring = 'abcd efgd 1234 fsdf gfds abcde 1234'
if i want to find which postion is 1234, how can i achieve this...? i
want to use index() but it only give me the...
|
by: vmoreau |
last post by:
I have a text and I need to find a Word that are not enclosed in
paranthesis. Can it be done with a regex? Is someone could help me?
I am not familar with regex...
Example looking for WORD:...
|
by: Ko van der Sloot |
last post by:
Hello
I was wondering which behaviour might be expected (or is required) for
the following small program.
I would expect that find( "a", string::npos ) would return string::npos
but is seems to...
|
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,...
| |
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |