12,763,337 members (36,929 online)
Rate this:
See more:
hi, i want to
select data from database between two dates where date datatype is datetime.

Posted 17-Oct-12 22:07pm
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:

Rate this:

## 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
Rate this:

## Solution 2

Look at this MSDN documentation page[^] section D.
Rate this:

## 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
v2
Rate this:

## 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';```
Rate this:

## Solution 6

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

Top Experts
Last 24hrsThis month
 OriginalGriff 235 Peter Leow 160 CPallini 145 ppolymorphe 130 Karthik Bangalore 100
 OriginalGriff 4,787 Peter Leow 3,554 ppolymorphe 2,923 Karthik Bangalore 2,814 Graeme_Grant 2,626