Need VBA help in extracting dates from an SQL String. . .

Lidsavr

Active Member
Joined
Jan 10, 2008
Messages
330
Hello, I run Excel 2007. . .

I run several reports that I have coded with help from this forum and it has made my job much easier.

Recently I made an error and ran the wrong set of date in a report. I extract data from a SQL database using a customer report writer that pull the data from the database. I input the dates and at the bottom of the report, I get a string like this:

Code:
SQL = select distinct sum(firstpass) as column1, count(totaltests) as column2, sum(implied) as column3, sum(impliedcount) as column4, customerid, assemblyno, processtyp, prodoriginctr AS fieldvalue FROM PLAID.dbo.EventYields (NoLock) where processtyp like '%' and firsttest between '19-Sep-11 00:00:00' and '25-Sep-11 23:59:59' and customerid like '345' and assemblyno like '%' and prodoriginctr like '603' group by customerid, assemblyno, processtyp, prodoriginctr ORDER BY 8, 5, 6, 7

If I can pull out the two dates, I know what to do to error proof the report.

Does anyone know of a way using VBA? (The two dates above are 19-Sep-11 and 25-Sep-11).

Thanks,

Charles
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hi, Try these formulae:
Code:
=MID(A1,SEARCH("and firsttest between",A1)+23,9)
=MID(A1,SEARCH("and firsttest between",A1)+48,9)
 
Upvote 0
al_b_cnu,
I know this is late; but I just want you to know that the formulas work great! I was pulled off of this job for a short while to tackle and end-of-the-year shipping issue and now I am back on the original programming task.

I appreciate the help!

Charles
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,717
Members
452,939
Latest member
WCrawford

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