Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Understanding DATEDIFF()
Message
De
16/04/2015 21:33:06
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2012
Application:
Web
Divers
Thread ID:
01618557
Message ID:
01618579
Vues:
23
>I am not sure what are you missing, I am sure missing something as my test works fine:
>
>
>declare @Holiday table ([Name] varchar(32), [Start] datetime, [End] datetime) 
>
>insert into @Holiday ([Name], [Start], [End]) values ('Christmas', '2014-12-24', '2015-12-24')
>insert into @Holiday ([Name], [Start], [End]) values ('New Year', '2014-01-01', '2015-01-01')
>
>SELECT [Holiday].[Name], SUM(DATEDIFF(d, [Holiday].[Start], [Holiday].[End])) from @Holiday Holiday group by [Holiday].[Name]
>
>-- Christmas	365
>-- New Year	365
>
>SELECT [Holiday].[Name], SUM(DATEDIFF(s, [Holiday].[Start], [Holiday].[End])) from @Holiday Holiday group by [Holiday].[Name]
>
>-- Christmas	31536000
>-- New Years	31536000
>
I will do some verifications. I found out, at first, I have duplicates in the data.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform