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
 SQL Server Development (2000)
 store procedure's problem

Author  Topic 

hong_ma
Starting Member

37 Posts

Posted - 2006-01-18 : 16:41:19
I have an user defined function and stored procedure. I can get a correct value from the user defined function.
after I pass the value which from user defined function to a stroed procedure. I couldn't get a correct value from the stored procefure. it looks like

dbo.adReporting.DateDue BETWEEN dbo.udfFYEDate(DateDue, dueday, ContactFYE) AND DateDue ) doesn't return a correct time period, but dbo.udfFYEDate(DateDue, dueday, ContactFYE) returns a correct value.


CREATE FUNCTION dbo.udfDisplayTime ( @dueday int, @FrequencyID int, @ContactFYE smalldatetime)
RETURNS smalldatetime AS
BEGIN
DECLARE @ReturnString AS smalldatetime
Declare @dueday1 as int
if (@FrequencyID =1)
BEGIN
set @dueday1 = @dueday -60
end

select @ReturnString = DATEADD ( dd, @dueday1, @ContactFYE)
Return @ReturnString

END




CREATE PROCEDURE dbo.asp_Reporting () AS

SELECT *

from join tables

where (dbo.adReporting.DateDue BETWEEN dbo.udfFYEDate(DateDue, dueday, ContactFYE) AND DateDue )

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-19 : 08:19:26
Refer this to know how to handle Dates
http://www.sql-server-performance.com/fk_datetime.asp

Post some sample data and the result you want

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

hong_ma
Starting Member

37 Posts

Posted - 2006-01-19 : 21:42:10
Thanks a lot. Do you think the problem is from "Between"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-20 : 01:09:21
Yes I think so

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -