Hallo Everyone,
I have this code that I use in SQL as stored procedures and I want that the date is in asc way from the latest date to the earliest date i.e. first of august to be the start and end of august to be the end.
This is the code:
SELECT SUM(Hours) as 'Total'
,CONVERT(char(7), date, 120) AS 'year',
FORMAT(Date, 'ddd', 'en-US') + '/' + CONVERT(VARCHAR(5),DATEPART(DAY,Date)) AS 'Day'
FROM Hemingways
WHERE CONVERT(char(7), date, 120) = '2021-07' OR '2021-07' IS NULL
GROUP BY CONVERT(char(7), date, 120), FORMAT(Date, 'ddd', 'en-US') + '/' + CONVERT(VARCHAR(5),DATEPART(DAY,Date))
order by FORMAT(Date, 'ddd', 'en-US') + '/' + CONVERT(VARCHAR(5),DATEPART(DAY,Date)) desc
and as results in desc get this :
Total, Year, Day
4.00 2021-07 Sat/17
4.50 2021-07 Fri/9
3.50 2021-07 Fri/16
and as results in asc get this :
Total, Year, Day
3.50 2021-07 Fri/16
4.50 2021-07 Fri/9
4.00 2021-07 Sat/17
which doest makes sense.
Any help is much appriciated