With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
The Grade of the Solution
The Zone Rank of the Expert Providing the Solution
The Number of Author and Expert Comments
The Number of Experts Contributing
The Feedback of the Community
Your Input Matters Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.
If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.
I have a column (notes) that is a string. This field is periodically updated and more information is appended to it. (Not my design). What I need to do is be able to look for the last date that is put into the string and then compare that date to see if it is between two other dates.
For the purposes of this question we can assume 1 table - table1 with 1 column - Notes.
A sample piece of data for the notes column would be...
blurb on 03/23/2004 by Someone blurb on 03/23/2004 by Someone blurb on 09/27/2004 by Someone Blurb on 09/27/2004 by Someone
Of course, I took the actual data out and replaced it with blurb to protect the innocent.
Hmm, I think that is the first date not the last (?). Please try this:
SELECT ... WHERE patindex('%[01][0-9]/[0123][0-9]/2[012][0-9][0-9]%', notes) > 0 --verify that a date pattern is present /* not sure what this does, it may still be needed and substring(notes, CHARINDEX (' on', notes, len(notes)-25)+4, 1) in ('0','1') */ -- find the *last* date pattern, convert it to a date, ... AND convert(datetime, substring(notes, len(notes) - (patindex('%[0-9][0-9][012]2/[0-9][0123]/[0-9][01]%', reverse(notes)) + 8), 10), 101) -- ... and compare it to the requested start and end dates BETWEEN @StartDate AND @EndDate
SET @StartDate = convert(datetime, '10/01/2006',101) SET @EndDate = convert(datetime, '06/30/2007',101)
set @notes = 'blurb on 03/23/2004 by Someone blurb on 03/23/2004 by Someone blurb on 09/27/2004 by Someone Blurb on 09/27/2004 by Someone' select convert(datetime, substring(@notes, len(@notes) - (patindex('%[0-9][0-9][012]2/[0-9][0123]/[0-9][01]%', reverse(@notes)) + 8), 10), 101) where patindex('%[01][0-9]/[0123][0-9]/2[012][0-9][0-9]%', @notes) > 0 --and convert(datetime, substring(@notes, len(@notes) - (patindex('%[0-9][0-9][012]2/[0-9][0123]/[0-9][01]%', reverse(@notes)) + 8), 10), 101) between @startdate and @enddate
ted, I'm a dba\network admin so my plate is kind of full. I'm plodding through a programming manual now but not enough time for this. My DB is relatively small so it returns pretty quick right now.
also, the and substring(notes, CHARINDEX (' on', notes, len(notes)-25)+4, 1) in ('0','1') was just a way to get rid of nulls and results with character since this the date is always the only number in the field and begins with 0 or 1. Not eloquent but it works. Thanks! I'll let you know how it goes..