Click here to Skip to main content
15,907,233 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi All,

I have a database that i insert data into it according to date.
Now i want to search and display my data acording to the date. for example ,i want to show the datas which are between two date that they had inserted.
How can i write it?
Thanks in Advance.
Posted
Updated 18-Jul-11 2:09am
v2

I am assuming you are talking about SQL query, if so then please visit the link,
Fetching records between two date ranges [^]

Hope it helps to solve your problem.
 
Share this answer
 
something like this:

SQL
DECLARE @DateA DATETIME, @DateB DATETIME
SET @DateA = --whatever
SET @DateA = --whatever
SELECT * FROM DummyTable WHERE
DATEDIFF(DAY, @DateA, @DateB) >= 0
 
Share this answer
 
Selects everything bewteen the two specified dates

SQL
select * from TableName where MyDateTimeColumn BETWEEN (GETDATE() and (GETDATE()-3)
 
Share this answer
 
Comments
Manas Bhardwaj 18-Jul-11 8:08am    
Never noticed it. Good to know!!! +5.
arr_date >= '" & Format(CDate(frmDate.Text), "yyyy/MM/dd") & "' and dep_date <= '" & Format(CDate(toDate.Text), "yyyy/MM/dd") & "'
 
Share this answer
 
Try Like this:
select * from TableName where MyDateTimeColumn BETWEEN (GETDATE() and (GETDATE()-3)


This will solve your problem.
 
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