Click here to Skip to main content
12,763,337 members (36,929 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET SQL-Server
hi, i want to
select data from database between two dates where date datatype is datetime.

please reply
Posted 17-Oct-12 22:07pm
Comments
Zoltán Zörgő 18-Oct-12 3:12am
   
Good for you. I suppose you wanted to formulate a question. This is not a question, this is a wish. But we are not Santa...
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

try these queries
select * from [tablename] where [datefrom] between [dateto]

OR
select * from [tablename] where convert(datetime,[datefrom],103)>'"+[valuefrom]+"' and convert(datetime,[dateto],103)<'"+[valueto]+"'


Thanks
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Look at this MSDN documentation page[^] section D.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Try this in where condition
WHERE ((CAST(FLOOR(CAST(SearchDate AS FLOAT)) AS DATETIME) 
	BETWEEN 
	CAST(FLOOR(CAST(@FromDate AS FLOAT)) AS DATETIME)
	AND CAST(FLOOR(CAST(@ToDate AS FLOAT)) AS DATETIME))

from above query you can check difference till dd/mm/yyyy hh:mm:ss
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

hi
check out the query
SELECT * FROM TableName where datetime between
to_date('01-oct-2012,'mm/dd/yyyy') and
to_date('30-oct-2012','mm/dd/yyy')
order by datetime DESC;


or
select column1, column2 from tablename where
convert(char(20),columnname,105) between '21-10-2012' and '19-10-2012';
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 6

select * from `tablename` where `datetime` >= '2012-01-01 00:00:00' and `datetime` <= '2012-12-31 23:59:59';
  Permalink  

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

    Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.170217.1 | Last Updated 18 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100