Skip to content

Instantly share code, notes, and snippets.

@yahyaahrika
Created August 31, 2021 09:17
Show Gist options
  • Save yahyaahrika/36b95a133fdee0938e60abba7926df33 to your computer and use it in GitHub Desktop.
Save yahyaahrika/36b95a133fdee0938e60abba7926df33 to your computer and use it in GitHub Desktop.
sql server date time convert to hours date to make charts date
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