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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 select records based on dates

Author  Topic 

TJ
Posting Yak Master

201 Posts

Posted - 2003-10-09 : 12:36:15
I'm using SQL7. I have stored procedures that select recordsets for Crystal reports. I need to add two input parameters to the sprocs to add to the where clause for the record selection.

create procedure Rec_Detail
@begdte as smalldatetime,
@enddte as smalldatetime
AS

begin
select
acctnum,
amount,
trantype,
trandate,
FROM tbl1
WHERE ACCTNUM < = '999999999' AND trandate between @begdte and @enddte
end


My issue with this is the time. I want everything between the beginning and the ending date regardless of the timestamp.

Any suggestions would be appreciated.

Thanks!
Teresa



"It's not what you take with you when you go;
but what you leave behind you when you're gone."

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-10-09 : 12:38:05
...
WHERE ACCTNUM < = '999999999' AND
trandate >= dateadd(dd,datediff(dd,0,@begdte),0) and
trandate < dateadd(dd,datediff(dd,0,@enddte)+1,0)

Jay White
{0}
Go to Top of Page

TJ
Posting Yak Master

201 Posts

Posted - 2003-10-09 : 12:45:35

quote:
Originally posted by Page47

...
WHERE ACCTNUM < = '999999999' AND
trandate >= dateadd(dd,datediff(dd,0,@begdte),0) and
trandate < dateadd(dd,datediff(dd,0,@enddte)+1,0)

Jay White
{0}



THANK YOU!!! That works great!

Sincerely,
Teresa
Go to Top of Page
   

- Advertisement -