Created
August 31, 2021 09:17
-
-
Save yahyaahrika/36b95a133fdee0938e60abba7926df33 to your computer and use it in GitHub Desktop.
sql server date time convert to hours date to make charts date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURE "SP_Statistique_UmsatzbyTime"( | |
@dateStart DATE, | |
@dateFin DATE | |
) | |
AS | |
BEGIN | |
SELECT | |
Concat(DATEPART(hh ,stardate ),':00') AS Hours , | |
FORMAT(sum(ISNULL(wr.sales, 0 )+ISNULL(wr.sales2, 0 )+ISNULL(wr.costt, 0 )) ,'N2') as umsatz | |
FROM iso.works wr WHERE | |
TRY_CONVERT(DATE, stardate) >= @dateStart AND TRY_CONVERT(DATE, stardate) <= @dateFin | |
GROUP BY DATEPART(hh , stardate ) | |
ORDER BY CASE when DATEPART(hh , stardate ) >= 6 then 0 ELSE 1 END ASC , DATEPART(hh , stardate ) ASC | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment