Click here to Skip to main content
15,888,733 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Anybody help me to get two different date rows values in sql server.

if i already added like this

" select * from Tablename where Columnname between '6/24/2013 12:00:00 AM' and '6/27/2013 12:00:00 AM' "

but this query will check only month and date so i got lot of rows. this is taken next year values also. so please help me anybody know the answer for this problem.

6/3/2013 12:00:00 AM 200 300 400 120
6/24/2013 12:00:00 AM 200 350 600 150
6/25/2013 12:00:00 AM 200 350 600 150
6/26/2013 12:00:00 AM 200 350 600 150
6/27/2013 12:00:00 AM 200 350 600 150
6/3/2014 12:00:00 AM 200 300 400 120
6/24/2014 12:00:00 AM 200 350 600 150
6/25/2014 12:00:00 AM 200 350 600 150
6/26/2014 12:00:00 AM 200 350 600 150
6/27/2014 12:00:00 AM 200 350 600 150
Posted
Comments
ArunRajendra 28-Jun-13 2:50am    
I tried with give dataset and it worked. can you give the real query?
Amol_B 28-Jun-13 2:58am    
if you column data type is date time then it will return proper results. it seems that you are storing date as varchar column
Savalia Manoj M 28-Jun-13 3:02am    
I also agree with you...
Savalia Manoj M 28-Jun-13 3:01am    
I also tried and it's working. Please check table's Datatype.
_Asif_ 28-Jun-13 12:06pm    
Your question is ambigious. Please explain a bit more

If your <Columnname> is datetime type then you could easily done it by likes below:

select * from Tablename where ([Columnname] BETWEEN '06-24-2013' AND '06-27-2013')

I hope this will help to you.
 
Share this answer
 
v2
first you need to check in what type the date format is?

http://www.sql-server-helper.com/tips/date-formats.aspx[^]

Check that link and see the date format types.

then using select statement you can get data.

Select * from [tbl_name] where <col_name> between 'YYYY-MM-DD HH:MM:SS' and 'YYYY-MM-DD HH:MM:SS'
 
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