Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
dear all,

i want to show between two dates data with the help of column name wise using sql server
i tried many other ways but am not. so please guide me for my solution.
please guide me is this possible to get output for the below query?
for example:

SQL
declare @fromdate datetime,@todate datetime
select @fromdate='2015-11-06 11:59:48.000', @todate='2015-11-11 13:22:27.000'

select *  from BillDetails1 where ProductName ='chokalate' between @fromdate and @todate



but am unable to get the result, on behalf of that am getting the below error,

error:
JavaScript
Incorrect syntax near the keyword 'between'.



thanks in advance..
Posted

1 solution

You need an AND plus a column name:
SQL
select *  from BillDetails1 where ProductName ='chokalate' AND MyDateColumn between @fromdate and @todate
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900