August 2, 2021 at 10:33 pm
Hello,
I have a code that suppose to give me weekly(summed) payments, but instead, it gives me random points, not (1*7, 2*7,...)
I suspect it maybe because it doesn't include the zeros, but i couldn't figure out how to fix it
Note: I use MySQL 5.1.41, so please give compliance code
August 3, 2021 at 10:10 am
This was removed by the editor as SPAM
August 3, 2021 at 10:22 pm
can you explain more ?
thanks for your reply
August 11, 2021 at 4:13 am
This was removed by the editor as SPAM
August 11, 2021 at 5:19 pm
Hello,
I have a code that suppose to give me weekly(summed) payments, but instead, it gives me random points, not (1*7, 2*7,...)
I suspect it maybe because it doesn't include the zeros, but i couldn't figure out how to fix it
Note: I use MySQL 5.1.41, so please give compliance code
You have not provided anything to go on to help you.
--Jeff Moden
Change is inevitable... Change for the better is not.
August 14, 2021 at 6:52 am
This was removed by the editor as SPAM
August 14, 2021 at 7:14 pm
SELECT DATEADD(DAY, -DATEDIFF(DAY, 0, [Order Date]) % 7, [Order Date]) AS [Week of],
COUNT(*) AS Count
FROM dbo.your_table_name
GROUP BY DATEADD(DAY, -DATEDIFF(DAY, 0, [Order Date]) % 7, [Order Date])
Welcome aboard! That's a great bit of code considering the OP offered almost no details.
It does seem to assume that weeks start on Mondays (which I totally agree with and is ISO). We'll see how the OP defines what a week is.
--Jeff Moden
Change is inevitable... Change for the better is not.
August 15, 2021 at 6:40 am
Campbell156 wrote:SELECT DATEADD(DAY, -DATEDIFF(DAY, 0, [Order Date]) % 7, [Order Date]) AS [Week of],
COUNT(*) AS Count
FROM dbo.your_table_name
GROUP BY DATEADD(DAY, -DATEDIFF(DAY, 0, [Order Date]) % 7, [Order Date])Welcome aboard! That's a great bit of code considering the OP offered almost no details.
It does seem to assume that weeks start on Mondays (which I totally agree with and is ISO). We'll see how the OP defines what a week is.
Not so sure about that. I live in the middle east and here the week starts at Sunday. I think that this would also be the case at most Muslim countries since for Muslims Friday is the holy day so the weekend starts at Friday and not at Saturday. In any case I agree with you that the original poster should have write more details.
Adi
August 15, 2021 at 5:04 pm
Jeff Moden wrote:Campbell156 wrote:SELECT DATEADD(DAY, -DATEDIFF(DAY, 0, [Order Date]) % 7, [Order Date]) AS [Week of],
COUNT(*) AS Count
FROM dbo.your_table_name
GROUP BY DATEADD(DAY, -DATEDIFF(DAY, 0, [Order Date]) % 7, [Order Date])
Welcome aboard! That's a great bit of code considering the OP offered almost no details.
It does seem to assume that weeks start on Mondays (which I totally agree with and is ISO). We'll see how the OP defines what a week is.
Not so sure about that. I live in the middle east and here the week starts at Sunday. I think that this would also be the case at most Muslim countries since for Muslims Friday is the holy day so the weekend starts at Friday and not at Saturday. In any case I agree with you that the original poster should have write more details.
Adi
A lot of companies here in the US do the same thing (week starts on Sunday). Even SQL Server defaults to Sunday start dates. I'm also familiar with the Muslim calendar you mention an other calendars such as the first day of the week being Thursday.
Just to be sure, none of the reasons I have for agreeing with Monday start dates have a thing to do with religion. Like I said, one of the reasons is that it's ISO compliant. The other reasons are mostly for computational convenience... 01 Jan 1900 and 01 Jan 1753 both occurred on Mondays.
Heh... I also like the fact that "the weekend" consists of two days that start with the same letter as some of my goals for weekends... simple, safe, stress-free, salubrious, satisfying, solitude. 😀
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply