Combining two columns into one parameter

Hi everyone. I have a query where I would like to search between a specific date range. The quirk to this though is that I want use that same date range on two different columns (ie ***.CreatedOn AND ***. ContactOn). 

I tried the following and obviously it doesn't work: 

SELECT *
FROM source tables
WHERE (dbo.dateonly(***.CreatedOn OR ***.ContactOn)) BETWEEN dbo.dateonly(@StartDate) AND dbo.dateonly(@EndDate)

Any insight would be GREAT. Thank you!
0
iklektic
12/16/2008 7:42:59 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

1 Replies
529 Views

Similar Articles

[PageSpeed] 24

 Try this if either condition is met by using OR, otherwise use AND to meet both conditions.

.... 

WHERE CreatedOn BETWEEN @StartDate AND @EndDate  OR  ContactOn AND  BETWEEN @StartDate AND @EndDate 


Limno

0
limno
12/16/2008 8:29:55 PM
Reply:

Similar Artilces:

How to combine two columns into one in an sql
I have an stored procedure that returns 3 columns. Month, Date, and Total Number of Calls. Here is the stored Proc: SELECT DATEPART(mm, CALLSTARTTIME) ,  DATEPART(dd, CALLSTARTTIME), COUNT(*) FROM CALL_LOG_MASTER WHERE (COMMERCIALS = '1') AND (PINCODE IS NOT NULL) GROUP BY DATEPART(mm, CALLSTARTTIME), DATEPART(dd, CALLSTARTTIME) ORDER BY DATEPART(mm, CALLSTARTTIME), DATEPART(dd, CALLSTARTTIME) It returns a table: MONTH   DATE   TOTAL NUMBER OF CALLS=======   =====   ===========1      ...

How to Combine two column in one table using SQL statement ?
Could you write the simple SQL statement from 'Combine two column in one table '? I try to use 'Union' which combine two column in two table . thx You can use the concatention operator (+): SELECT column1 + column2 AS myColumn FROM myTable TerriTerri MortonEngagement Manager, NeudesicHow to ask a question If the columns are numeric then "+" will sum the column values. If you do not desire this, you should use str() function Check the below statement, select ltrim(str(column1)) + ltrim(str(column2)) from mytable http://www.eral...

Combine Two Different Columns into one column
Hi Guys,   I have twotables(Employee and Borrower). In Employee table have EMPID and Borrower table have BorrowerID. I want to comebine these two columns into one column as EMPID  in Employee table. Can  any one help? Thanks what is realtion between to tables ?   Use    Union Thanks for reply. Acutally Employee table EMPID, NAME Columns. in this Employee table had 12000 rows. Borrower table has BorrowerID,BType etc.. .Here Employee ID and BorrowerID both are same. This table has 16000 rows. Now my what i want to do is Come EMPID and BorrowerID and ...

SQL query to one column od database into two columns
Hi,I have a empskill Table which has 3 Columns (1) EmpID (2) SkillTypeID and (3) CourseID.Now  SkillTypeID column has data 1 or 2 .......in here 1 means Primary Skill and 2 means Secondary Skill. CourseID will reflect the ID's of subjects like c#,SQL,etc I need a Query which will count the number of primary skilled and number of secondary skilled persons based on subject and will display as followsCOURSE ID      SKILL TYPE  21                        222  &n...

SQL: mutiple rows one column to multiple columns one row
In InfoMaker SQL can you take a table with multiple rows for the same key and take a column from the rows and create mutiple columns with one report line with the key(no duplicate keys) on a report? For example Table books (key) (book title) 123 misery 123 titanic 123 roots 456 war 456 1984 456 giant The report I need would look like this Key title1 title2 title 3 123 misery titanic roots 456 war 1984 giant Thanks in advance. -- Kaye Hendry HealthInsight email:kaye.hendry@healthinsight.org ...

How to combine two SQL Datasource and put it in GridView?
Hi, I'm trying to combine two datasources together. The reason I have to combine them is because, one database is used by a software that I can't manipulate, the other database is exact one I created for an internal custom software. They both have different connectionstrings. I have the VB code below. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)Dim PCConnectionString As String = "Data Source=Source1;Initial Catalog=Center;Persist Security Info=True"Dim PCcon As SqlConnection = New SqlConnection(PCConnectionString)Dim TCConnectio...

C# how do you combine two db column into one
I have a storedprocedure and database with a column firstname and a column lastname. I would like to combine these column into one so that the name would read "Joe Blow" in the database. What is the syntax for that?  Below is the SP: (@host varchar(50), @action varchar(50), @firstname varchar(50), @lastname varchar(50)) as Insert into logs (host, action, firstname, lastname) VALUES (@host, @action, @firstname, @lastname) You need to use + to concat 2 values something like this FirstName + ' ' + LastName   Take care,Se...

how to combine two sql commands in one DeleteCommand
Is there any way to have the SqlDataSource DeleteCommand execute two sql commands. That is, something like: DeleteCommand="DELETE FROM [HRMFile] WHERE [id_file] = @original_id_file;DELETE FROM [HRMFileLap] WHERE [id_file] = @original_id_file"> If not, is there a simple example of how to connect a stored procedure to the datasource. (like a tutorial or article?) Thanks, and Happy New Year!!! Peter Kellnerhttp://73rdstreet.com and blogging athttp://PeterKellner.netMVP, ASP.NET The Sql Statement in your example, should do what you want, but I would suggest you use ...

how to split the content of one column in the objectdatasource into two parts and let them display in two columns in the GridView?
i combine the title and the body of one article and store it in one column in the database,but i want to show the title and body seperately in the GridView,how should i achieve this goal?thank you so much for your advice!!! you can write the logic of splitting the column into two (title and body) in the query itself by which you are filling the datasource..Thanx, [KaushaL] || BloG || Profile || Microsoft MVP"I would love to change the world, but they won’t give me the source code"Don't forget to click "Mark as Answer" on the post that helped you.This credits that me...

combine two tables with different columns in sql sever
Hi, I have a requirement like.. One table has 12 columns for all month  with different year.  Lets say i need values from sep-2008 to Mar-2009. I need to select the values from sep-2008 to dec-2008 as a single table and jan-2009 to Mar-2009 values as a single table. Now i need to combine these two table as a single table. Please help how to combine two tables with different columns. Thanks, Prabha  The question is unclear (put samples of exact data structure, test data and desired output). I think you need to look at UNPIVOT operator in SQL Server 2005. Look at the H...

How to pass parameter value from one sql datasource to another?
Hi everybody, Here is the problem, how to pass the values from one datasource to another one on the same aspx page, without coding?  I have a page with FormView control to present data for one selected record from a search page, with edit item and insert item templates created. The main sql datasource keeps control on everything with select, update, delete and insert methods. For insert I am using existing stored procedure, for which the wizard generated all the required parameters. In Command and Parameter Editor I can see them, and I need to define all of th...

Trying To Combined two data fields in one DataGrid Column
I am trying to combined two data fields in one DataGrid column.The following is what I have now.  It did not work.  THE "<" WHERE REPLACE WITH "{".ANY SUGGESTIONS.{asp:DataGrid ID="DataGrid1" Runat="server" BorderColor="Black" GridLines="Vertical" CellPadding="4"                CellSpacing="0" width="450" Font-Names="Arial" Font-Size="8pt" ShowFooter="True" HeaderStyle-BackColor="#cccc99"                FooterStyle-BackCo...

Combining Two Fields from a SQL DB into One Dropdown box
What I am trying to do is to concatenate 2 fields from a table into 1 dropdown box. It comes up with an error when it tries to do a Databind. lblDept.Text = ("ID") & " - " & ("Description") ddlDept.DataTextField = lblDept.Text ddlDept.DataSource = GetDept() ddlDept.DataBind() What am I missing? Thanks, Ralph Hi Ralph, You may modify the SELECT statement as: SELECT ID + ' - ' + Description AS FullDetail FROM ... Then, set the FullDetail as the DataTextField. Colt Thanks for info....it works wonde...

How to pass two parameter in One Like Operator in Sql server
 Hi All,         I wanted to pass two parameter in one like operator.         if i pass firstname or lastname then record should be come then how to use?            Select * from test where username like  '%@firstname,@lastname%'    Regards,Pankaj Kumar SinghMS International Inc.  Try this:  Select * from test where username like  '%'+@firstname+'%'   OR username like  '%'+@lastname+'%' Limno...

Web resources about - Combining two columns into one parameter - asp.net.sql-datasource

Protein combining - Wikipedia, the free encyclopedia
Protein nutrition is complex because any proteinogenic amino acid may be the limiting factor in metabolism . Mixing livestock feeds can optimize ...

4 ways to benefit from combining Facebook brand & direct marketing
... marketing as a brand activity – not one that can drive conversion directly . However, it doesn’t have to be an either-or proposition. By combining ...

Brain Wave Sharp Mind ™ - 11 Binaural Brainwave Entrainment Programs combining Binaural Tones with Soothing ...
Get Brain Wave Sharp Mind ™ - 11 Binaural Brainwave Entrainment Programs combining Binaural Tones with Soothing Ambient Nature Sounds, iTunes ...

The Cruise Director: combining cruise and rail holidays
Combining a cruise with a rail journey is an increasingly popular choice around the world.

High paying job in Australia: Data scientist combining maths, marketing - DailyTelegraph Search Search ...
MATHS and marketing are the keys to a big pay packet, with one new occupation offering $200,000 a year and predicted to become a staple in businesses ...

High paying job in Australia: Data scientist combining maths, marketing
MATHS and marketing are the keys to a big pay packet, with one new occupation offering $200,000 a year and predicted to become a staple in businesses ...


Combining last names
... couples have come up with an interesting solution. CBC.ca home Help Search the CBC Player Submit Search News - Oct 17, 2013 - 10:36 Combining ...

Combining Political Trips With Official Business Isn't New At All
OTTAWA - Announcement, political rally, photo-op, political rally, announcement, repeat as needed.The prime minister's travel agenda these days ...

Xinhua Insight: Combining population and economic policy to push development
Xinhua Insight: Combining population and economic policy to push development People's Daily Online BEIJING, March 13 (Xinhua) China's fresh ...

Resources last updated: 12/31/2015 6:38:32 AM