return datediff function from user defined function.

return datediff function from user defined function.

Post by kasp » Tue, 10 Apr 2001 23:26:50



hello!

May be somebody know how can i return table from user defined function if i
use "datediff" function ,
like this:


   SELECT TOP 100 PERCENT rec_id, recordnick, date_diff=datediff(day,
recorddate, getdate()) ,  recordon
    FROM tblForum_Records   WHERE left(recordid, 9) BETWEEN

and recordon=1
 RETURN

the error is invalid use of 'getdate' with a function

thank you.

 
 
 

return datediff function from user defined function.

Post by Tibor Karasz » Tue, 10 Apr 2001 23:02:45


Kaspi,

Pass the current datetime as an inparameter to the function.

--
Tibor Karaszi, SQL Server MVP
FAQ from Neil at: http://www.sqlserverfaq.com
Please reply to the newsgroup only, not by email.


> hello!

> May be somebody know how can i return table from user defined function if i
> use "datediff" function ,
> like this:


>    SELECT TOP 100 PERCENT rec_id, recordnick, date_diff=datediff(day,
> recorddate, getdate()) ,  recordon
>     FROM tblForum_Records   WHERE left(recordid, 9) BETWEEN

> and recordon=1
>  RETURN

> the error is invalid use of 'getdate' with a function

> thank you.


 
 
 

return datediff function from user defined function.

Post by kasp » Wed, 11 Apr 2001 00:10:22


like that?

select * from userdefinedfunction(par1,par2, getdate()).?



> Kaspi,

> Pass the current datetime as an inparameter to the function.

> --
> Tibor Karaszi, SQL Server MVP
> FAQ from Neil at: http://www.sqlserverfaq.com
> Please reply to the newsgroup only, not by email.




> > hello!

> > May be somebody know how can i return table from user defined function
if i
> > use "datediff" function ,
> > like this:


> >    SELECT TOP 100 PERCENT rec_id, recordnick, date_diff=datediff(day,
> > recorddate, getdate()) ,  recordon
> >     FROM tblForum_Records   WHERE left(recordid, 9) BETWEEN

char(255))
> > and recordon=1
> >  RETURN

> > the error is invalid use of 'getdate' with a function

> > thank you.

 
 
 

return datediff function from user defined function.

Post by Tibor Karasz » Tue, 10 Apr 2001 23:19:42


Almost. Unfortunately, you cannot pass the function execution like that. Do something
like:




--
Tibor Karaszi, SQL Server MVP
FAQ from Neil at: http://www.sqlserverfaq.com
Please reply to the newsgroup only, not by email.


> like that?

> select * from userdefinedfunction(par1,par2, getdate()).?



> > Kaspi,

> > Pass the current datetime as an inparameter to the function.

> > --
> > Tibor Karaszi, SQL Server MVP
> > FAQ from Neil at: http://www.sqlserverfaq.com
> > Please reply to the newsgroup only, not by email.



> > > hello!

> > > May be somebody know how can i return table from user defined function
> if i
> > > use "datediff" function ,
> > > like this:


> > >    SELECT TOP 100 PERCENT rec_id, recordnick, date_diff=datediff(day,
> > > recorddate, getdate()) ,  recordon
> > >     FROM tblForum_Records   WHERE left(recordid, 9) BETWEEN

> char(255))
> > > and recordon=1
> > >  RETURN

> > > the error is invalid use of 'getdate' with a function

> > > thank you.