>Hi, I'm not quite sure I follow the original problem, but if you want the SQL equivalent....I've kept the parameter order the way you wanted, though personally I think you want to reverse them.
>
>Here is SQL equivalent.. Not sure if this will solve everything you're encountering, but here goes.
>
>
>CREATE FUNCTION dbo.DaysToComplete
>(@CloseDate Date, @OpenDate Date)
>RETURNS INT
>AS
> BEGIN
> DECLARE @DayDiff int = DATEDIFF(D, @OpenDate, @CloseDate)
> if @DayDiff < 0
> set @DayDiff = 0
> return @DayDiff
> end
>
>
>Here are 2 tests...
>
>
>select dbo.DaysToComplete( '5/1/2014', '5/15/2014') returns zero
>select dbo.DaysToComplete( '5/15/2014', '5/1/2014') returns 14
>
This has been a tremendous help. Thank you!
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham