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 |
|
John T.
Posting Yak Master
112 Posts |
Posted - 2003-06-24 : 09:59:34
|
| Hello forum. Hope all is well in SQL Land. I am doing a query in which I am trying to get records between a date range, inclusive. If I ask for June 18 through June 23. I want June 18, ...., June 23 results. The following is giving me the first date, June 18. But stops at June 22.Where (Name = @Name) and (GDate between convert(smalldatetime,@Date1) and convert(smalldatetime,@Date2)) and (Type like @Type) and convert(varchar(50),Un) like @UnVarGDate is a smalldatetime table value. |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-06-24 : 10:16:13
|
| You probably have the time included in the date so it will not get any data for the last date.try(GDate >= convert(smalldatetime,@Date1) and GDate < dateadd(dd,1,convert(smalldatetime,@Date2)))or (GDate between convert(smalldatetime,@Date1) and dateadd(dd,1,convert(smalldatetime,@Date2)) and GDate <> dateadd(dd,1,convert(smalldatetime,@Date2)))==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
John T.
Posting Yak Master
112 Posts |
Posted - 2003-06-24 : 10:41:37
|
| Thanks very much. Got it working just fine. Nice to know about the time affecting the query. |
 |
|
|
|
|
|
|
|