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
 General SQL Server Forums
 New to SQL Server Programming
 DateDiff question

Author  Topic 

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2010-09-28 : 10:21:09
Hello everyone

I want to use the DateDiff function within a UDF

for example

select DateDiff (day, INVDATE , getdate())
from customer_statement_PB
where ( "the difference is more than 50" )

what is the syntax to implement the >50 criteria.

Kind Regards

Rob


MCTS / MCITP certified

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-09-28 : 10:54:15
Are you using sql server 2000 or 2005 ?

AFAIK in Sql 2K you cannot use getdate() (non-deterministic function) inside UDF. You need to pass as parameter.

In Sql 2K5 I feel we can use getdate() function.

The select will be:
select DateDiff (day, INVDATE , getdate())
from customer_statement_PB
where DateDiff (day, INVDATE , getdate()) > 50

Go to Top of Page

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2010-09-28 : 11:05:19
Hello there

yeah sql server 2005
Go to Top of Page

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2010-09-28 : 11:17:38
how would i tie this into a column constraint?
Go to Top of Page

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-09-28 : 11:32:45
quote:
Originally posted by masterdineen

how would i tie this into a column constraint?



what you mean by "tie this into a column constraint".

You don't want user to enter the data older than 50 days ?
Go to Top of Page

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2010-09-28 : 11:36:03
No I just want to have a column, for example stating how many days over due

working off a datediff from datetime column.
Go to Top of Page

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2010-09-29 : 04:13:58
Good morning everyone,

does anyone have any ideas on this on please?
Go to Top of Page
   

- Advertisement -