>>select * from MyTable where DAYSTOCOMPLETE( DATE_CLOS, DATE_OPEN)>23)
>>
>>Where DATE_CLOS and DATE_OPEN are two column names of the table. Should this code work or I have to change the syntax?
>
>
>First, I'd recommend always referencing the schema..... WHERE dbo.DaysToComplete....
>
>Second, performance will be better if you do it inline....
>
>WHERE DATEDIFF(D, OpenDate, CloseDate) > 23
>
>I'm not a fan of scalar functions in SQL, because you can get really bad performance sometimes. Unless the benefit of a function is much higher than performance, it's better to use it inline.
Do I understand correctly that DATEDIFF() is a "standard" SQL Function that accepts three parameters? (sorry for so many questions).
"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