Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Sort by day, ignoring hours and minutes

I have a little problem for you. I would like to sort by day, but if several with different times are sorted on the day, it separates them. How do I get it out that he only shows all day by day

My date field looks like this

Datum                         weight
2022-12-09 07:12:49.000       2150
2022-12-09 08:15:49.000       1250

My query

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Select FORMAT(Datum, 'dd/MM/yyyy', 'de-DE') as Datum, SUM(weight)
FROM [Produktionsdaten].[dbo].[produktionedelstahl]
WHERE Anlage IN ('Bonak 2')
  AND YEAR(Datum)=YEAR(CURRENT_TIMESTAMP)
  AND MONTH(Datum)=MONTH(CURRENT_TIMESTAMP)
group BY (Datum)

I want the day to be summarized

Datum           weight
12-09-2022      3400

>Solution :

I think you were nearly there – just change the last line

Select FORMAT(Datum, 'dd/MM/yyyy', 'de-DE') as Datum, SUM(weight)
FROM [Produktionsdaten].[dbo].[produktionedelstahl]
WHERE Anlage IN ('Bonak 2')
  AND YEAR(Datum)=YEAR(CURRENT_TIMESTAMP)
  AND MONTH(Datum)=MONTH(CURRENT_TIMESTAMP)
group BY FORMAT(Datum, 'dd/MM/yyyy', 'de-DE')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading