Expression similar to SEARCH within a query

jonlj

New Member
Joined
Dec 10, 2004
Messages
19
Hi,

Is there a command similar to SEARCH (excel) that I can use in an expression in a query. Trying to extract a date from a string of text that is not in a fixed position for every record hence cant use MID.

Many thanks
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Not 100% sure what you mean.

Can you give an example?

There are methods you might use one is the InStr function and the other the Like operator.

Which to use depends on what you want to do.
 
Upvote 0
In the raw table i have a column with data similar to
"Last Modified on 12/30/2003 at 3:09:37 PM". However the text preceeding the date is changing. I want the column in my query to just show the date. Expr1: DateValue(Mid([mod],17,10)) in this example this would give the right result for that row but not the next where the record has less text preceeding the date. I need to trap the location of the first "/" if i can so I am able to pick the date out.
 
Upvote 0
Could you give more examples?

By the way how is this data being generated/imported into Access?
 
Upvote 0
Row1: Last Modified on 8/9/2004 at 3:09:32 PM
Row2: Modified on 8/10/2004 at 4:19:16 PM
Row3: Deleted on 8/11/2004 at 6:31:11 PM (u123456)

Importing directly from excel

Thanks
 
Upvote 0
Do you have any control over the Excel spreadsheet?

Are these entries being created in Excel via code?

If they are I would suggest going back to that code and altering it to seperate the date/time and action into seperate columns.
 
Upvote 0
Cant do that. I have an excel sheet per day for the last 3 years just ftp'd to me. I'm writing a looping import to append all data to a main table. I dont want to have to utilise excel for this. I guess I could try writing a new function in access to do this.. (maybe not something i should consider at 5pm on a Friday evening)
 
Upvote 0
Hi,
this won't stop the problem from occuring, as Norie has pointed out, but assuming the string always has the words "on" and "at" around the date then one way of extracting the date would be using something like this :

Mid([text], InStr([text], "on") +3, InStr([text], "at") -InStr([text], "on") -4)

in your query. Be sure to use your actual field name where I have used 'text'.
HTH, Andrew. :)
 
Upvote 0

Forum statistics

Threads
1,221,907
Messages
6,162,777
Members
451,788
Latest member
Hideoshie

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top