Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Replacing VFP Function with SQL Server
Message
 
 
À
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:
01609077
Vues:
47
>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
>
This has been a tremendous help. Thank you!
"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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform