Skip to content

Using groupBy with date part #204

Open

Description

@gbergamo

Hi.. I cannot find a way to group by my array with a date part (dd/MM/yyyy).
I have to group by day/month/year of a date property, how can I do it?

thanks!

Activity

  1. rafaelss95 commented on Jun 19, 2016

    @rafaelss95

    What's your data structure?

  2. gbergamo commented on Jun 20, 2016

    @gbergamo
    Author

    Messages = [
    { id: 1, sent: Date(), message: "" },
    { id: 1, sent: Date(), message: "" }
    ]

    It's something like that... 'Sent' is timespam
    I want to group messages by MM/dd/yyyy

    Thanks

  3. rafaelss95 commented on Jun 21, 2016

    @rafaelss95

    Well, I had a problem with groupBy with dates because my dates were formatted as timestamp, so I changed the format to MM/dd/yyyy before render the view, then it worked. You can format them both server-side as client-side.

  4. gbergamo commented on Jun 21, 2016

    @gbergamo
    Author

    To resolve that I use map function to before groupBy, so, on map function I create a new formatted property (MM/dd/yyyy).
    It works, but I don't know if that is the better way to do that. (honestly, I didn't like the solution)

    ng-repeat="(key, value) in mensagens | map: dateFormatter | groupBy: 'dateFormatted'"

  5. karandesai28 commented on Jun 1, 2017

    @karandesai28

    Above solution proposed by @rafaelss95 can work if I want to group by date. But I have a requirement to group by Date as well as time (complete timestamp), and in such cases groupBy is misbehaving. It would be great if someone would investigate the issue.

  6. karandesai28 commented on Jun 1, 2017

    @karandesai28

    @codekraft-studio Thanks for reply. Just to confirm, I mentioned about groupBy, not orderBy. Will it work for groupBy? I'll try from my end though.

  7. karandesai28 commented on Jun 1, 2017

    @karandesai28

    Well I tried in groupBy, but it didn't work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions