Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
zubairmasoodi
Starting Member
35 Posts |
Posted - 2007-05-15 : 01:42:49
|
| hi SELECT * FROM aS_tblPresentationsWHERE CONVERT(VARCHAR,CreatedDateTime,101) BETWEEN CONVERT(VARCHAR,'10/3/2006',101) AND CONVERT(VARCHAR,'5/15/2007',101)The above query Returns me 0 results from my database even though the table contains hundreds of records in the specified data range what is the reason, where i am doing wrong ?Thanks With regardsZubair Masoodi (Every day's a school day) |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-05-15 : 01:50:54
|
| [code]where dateadd(day, 0, datediff(day, 0, CreatedDateTime)) betweeen '20061003' and '20070515'[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-05-15 : 04:18:08
|
| www.sql-server-performance.com/fk_datetime.asp for more info on how to query on datesMadhivananFailing to plan is Planning to fail |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-05-15 : 06:16:09
|
| where CreatedDateTime >= '20061003' and CreatedDateTime < '20070516'Peter LarssonHelsingborg, Sweden |
 |
|
|
zubairmasoodi
Starting Member
35 Posts |
Posted - 2007-05-15 : 08:38:52
|
| i appreciate ur responses But i want to know what is the reason, where i am doing wrong ?ThanksWith regardsZubair Masoodi (Every day's a school day) |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-05-15 : 08:51:33
|
Run the following query and see the resultSELECT CONVERT(VARCHAR, CreatedDateTime, 101), case when CONVERT(VARCHAR, CreatedDateTime, 101) >= '10/3/2006' then '>= 10/03.2006' else '' end, case when CONVERT(VARCHAR, CreatedDateTime, 101) <= '5/15/2007' then '<= 5/15/2007' else '' endFROM aS_tblPresentations KH |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-05-15 : 09:00:56
|
| Also read the link I postedMadhivananFailing to plan is Planning to fail |
 |
|
|
zubairmasoodi
Starting Member
35 Posts |
Posted - 2007-05-15 : 09:06:41
|
| The First Case returns '' empty column, means No date in my Table is greater than '10/3/2006'. but honestly i am still saying the problem is not yet clear to me why its happening ? below is sample dataCreatedatetime 03/29/2007 <= 5/15/200703/22/2007 <= 5/15/200703/22/2007 <= 5/15/200703/22/2007 <= 5/15/200703/23/2007 <= 5/15/200703/23/2007 <= 5/15/200703/23/2007 <= 5/15/2007Thanks With regardsZubair Masoodi (Every day's a school day) |
 |
|
|
|
|
|
|
|