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.
| Author |
Topic |
|
Velnias
Yak Posting Veteran
58 Posts |
Posted - 2008-10-14 : 10:47:07
|
| Hi What I would like to do is as follows1)Input Parameters are two dates 2) COmpare difference between the two dates3) Retrieve the difference and calculate wether it is a) less than 0 Days, between 0 and 30 and greater than 304) Based on where the value drops return a different string5) Retrieve the string in .netthis is in sql2005 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-14 : 10:56:50
|
| [code]CREATE FUNCTION GetDiffStatus(@Start datetime,@End datetime)RETURNS varchar(100)ASBEGINDECLARE @Diff int,@RetStatus varchar(100)SET @Diff=DATEDIFF(dd,@Start,@End)SET @RetStatus =CASE WHEN @Diff=0 THEN 'FirstValue' WHEN @Diff BETWEEN 0 AND 30 THEN 'Second Value' ELSE 'ThirdValue' ENDRETURN @RetStatusEND[/code]then call this as follows[code]SELECT dbo.GetDiffStatus(startdatevalue,enddatevalue)[/code]then use a variable in .net to receive this value |
 |
|
|
Velnias
Yak Posting Veteran
58 Posts |
Posted - 2008-10-14 : 11:41:55
|
| Thanks a lot visakh16 worked nicely |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-14 : 12:43:12
|
quote: Originally posted by Velnias Thanks a lot visakh16 worked nicely
welcome |
 |
|
|
|
|
|