Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group_By_Day_Of_Week is off by 1 (Monday returns as Sunday) #202

Closed
JSanderbeck opened this issue Jul 12, 2018 · 7 comments
Closed

Group_By_Day_Of_Week is off by 1 (Monday returns as Sunday) #202

JSanderbeck opened this issue Jul 12, 2018 · 7 comments

Comments

@JSanderbeck
Copy link

From a previous issue that was closed without resolution...

I have a chart that shows the number of incidents by the day of the week. The school is only open Monday thru Friday, and I verified all records are in the range of Monday thru Friday, however this line of code draws a chart from Sunday to Thursday.

@records.group_by_day_of_week(:entry_date, week_start: :sun, format: '%a').count

From the description in the previously reported bug, you stated that DAYOFWEEK returns a 1 for Sunday to a 7 for Saturday. This is incorrect in the later releases of Postgresql.

----- From Postgresql Documentation
The function receives the date variable d as its only argument and returns an integer that indicates the day of the week for this date.

0 - Sunday
1 - Monday
2 - Tuesday
3 - Wednesday
4 - Thursday
5 - Friday
6 - Saturday

image

Any suggestions on a way around this, or is a fix coming?

John

@ankane
Copy link
Owner

ankane commented Jul 12, 2018

Hey @JSanderbeck, check out the section on date columns in the readme to see if that fixes it.

@JSanderbeck
Copy link
Author

I tried changing the week start and it just changed what the first day in that chart was. Sunday still contained data...

@ankane
Copy link
Owner

ankane commented Jul 12, 2018

@JSanderbeck
Copy link
Author

But I NEED group_by_day_of_week, not just week...

@ankane
Copy link
Owner

ankane commented Jul 12, 2018

The specific function isn't important in the example - it's the time_zone: false part.

@ankane
Copy link
Owner

ankane commented Jul 12, 2018

Anyways, I don't think this is an issue with Groupdate, but happy to revisit if there's more evidence.

@ankane ankane closed this as completed Jul 12, 2018
@JSanderbeck
Copy link
Author

Ok. I understand what you are saying... That worked...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants