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 |
stevenc49
Starting Member
14 Posts |
Posted - 2008-07-18 : 14:50:56
|
If you have @startdate and @enddate parameters, the @enddate is inclusive because it goes to 00:00:00.For example, if I want data for the time period from January 1, 2008 to January 5, 2008 inclusive. The @startdate would be 1/1/08 and @enddate would be 1/6/08.Can I make it so that the user will just need to enter 1/5/08? |
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2008-07-18 : 14:52:27
|
concatenate the time '01/05/2008 23:59:59.99'or try thisdeclare @enddate as datetimeset @enddate = '1/5/08'select @enddateset @enddate = @enddate + 1select @enddate"God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
 |
|
stevenc49
Starting Member
14 Posts |
Posted - 2008-07-18 : 14:57:36
|
Sorry, I should've been more specific.In my query, I got:WHERE CREATED BETWEEN @startdate AND @enddateI tried:where CREATED BETWEEN @startdate AND '@enddate 23:59:59.99'but it says it failed to convert from datetime to character stringIs there a correct way to do that? |
 |
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2008-07-18 : 15:02:29
|
declare @startdate as datetimedeclare @enddate as datetimeset @startdate = '1/1/08'set @enddate = '1/5/08'set @enddate = convert(varchar(10), @enddate, 101) + ' 23:59:59'select @startdate, @enddate"God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|
|