Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Replacing VFP Function with SQL Server
Message
De
09/10/2014 13:07:40
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2014
Application:
Web
Divers
Thread ID:
01609065
Message ID:
01609067
Vues:
61
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform