473,383 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Using Like statement in parameters

I have a stored procedure that I need to modify and I would like to use the LIKE clause instead of the BETWEEN in a date range. I am running a report that calls this stored procedure and right now it is using @StartDate and @EndDate. I want to use LIKE. here is a sample of what I am wanting to change.

Expand|Select|Wrap|Line Numbers
  1. SELECT @Contracts = Count(AppID) 
  2. FROM #TEMP 
  3. WHERE Dealer = @vDealer 
  4. AND StatusAppDetail = 'A' 
  5. AND (DateContractFunded between @StartDate AND @EndDate)
I have a parameter in a report that calls the stored procedure and puts a date range which replaces the StartDate and EndDate. It is not pulling all the records for the date range because for some reason it cuts off after 7:00 pm and doesn't pull everything for the daterange. When I use the LIKE clause it works fine. Any help woulde be appreciated.



Jason
May 3 '11 #1
5 1863
code green
1,726 Expert 1GB
Your second paragraph seems to contradict the first.
It works with LIKE but you want to use LIKE?

iS DateContractFunded a DATETIME data type?
May 4 '11 #2
Ok, I guess I got too excited asking my question. The DateContractFunded is a DATETIME data type. I have used several different ways to pull the data but for some reason, it only pulls all the data using the LIKE clause. I want to get rid of the BETWEEN and use the LIKE to pull a date range. When I run my report, there is a @StartDate and @EndDate parameter which populates the @StartDate and @EndDate in the stored procedure. I don't know of any other way to pull a date range using a parameter in BO that will give me all the records. What I want is all the records in a date range tha I specify so if I want everything form 1-1-2011 to 1-31-2011 I want every single record with that date range regardless of the time stamp. If ther is another way or something easier, please inform me. I am struggling here! Thanks.
May 4 '11 #3
ck9663
2,878 Expert 2GB
Here, start with this.

Happy Coding!!!

~~ CK
May 4 '11 #4
bvrwoo
16
You must cast it to datetime because my default the DBO will save it as a text.
Aug 29 '11 #5
NeoPa
32,556 Expert Mod 16PB
You're using @StartDate and @EndDate, but you really want to specify DateTimes. It's natural you'll struggle if your names don't reflect what you're trying to achieve.

As a Date value reflects the time at midnight at the start of that date you probably want to ensure the @StartDate (DateTime) value is set to midnight of the start date of the range, and the @EndDate (DateTime) value is set to midnight of the day following the date range. Not too many real-life DateTime values turn up as midnight (not in most businesses anyway).
Sep 1 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Russell Mangel | last post by:
Is it possible to use the using statement with XmlTextReader? I tryed to use it, but it gives me the error message: Cannot implicitly convert type 'System.Xml.XmlTextReader' to...
5
by: Bill Priess | last post by:
Hey gang, Ok, I'm stumped on this one... I am using the using statement to wrap a SqlDataAdapter that I am using to fill a DataTable. Now, what I need to know is, just how much block-scope...
1
by: Kepler | last post by:
I have a situation where I need to use a Using statement that creates some records in a database. After that completes, if it completes, I need to do some file creation. Any code I'm putting...
8
by: J-T | last post by:
I have a class like below I have a couple of questions about that: 1) I like to use "Using statement" when creating an object of this class,so I had to implement IDisposable.Am I doing this right...
1
by: pascal_pare | last post by:
Hi, Is there a way to declare a using statement with the CodeDom? Something like: using (obj = new Object()) { obj.DoSomething; }
2
by: Robert Bravery | last post by:
Hi all, Being new to C# and .net I often don't know how to use things. I have created an app that imports excel data, it works well, with methods to open excel, extract the data and close excel....
5
by: Hillbilly | last post by:
MSDN Remarks "as a rule" the using statement should be used when instantiating objects which inherit IDisposable. Other than the obvious unmanaged objects like the file system example, fonts and...
3
by: CSharper | last post by:
I have a using statement something like the following try { using(SqlConnection cnn = ...) { } catch(Exception e1) { }
2
by: mcfly1204 | last post by:
What is the best practice for returning values from within a using statement? For instance: using (SqlConnection Conn = new SqlConnection(strConn)) { ...
2
by: dowlingm815 | last post by:
I have a between statement within a query for a date range as follows: between #6/1/2010# and 6/30/2010# What are the between statement parameters rules? I am dropping the records on the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.