Closed ninasleepyhead closed 3 years ago
I am facing the same issue with Dates not working in the order pipe. That would be a great feature as they are obviously orderable and it seems like a common use case, e.g. for dates in an event list.
Thanks for the module btw - and let me know if you need man power assistance with adding this functionality.
Hi VadimDez,
Thanks for your plugin. It's great but I'm also having the same problem when I sort the dates.
I am using Angular: 5.2.2 and ngx-order-pipe: 2.0.1.
My format show is: 'LLL-dd-yyyy')
Could you help us?
Thanks, Francisco
Hi everyone,
If you use a string type instead of a date type, the sort works properly!
I hope this will help. Francisco
Hi everyone,
Yes, if your original date format is similar like 'yyyy-MM-dd'(put the year in the front), the sort works great. And then you can use Angular date pipe to change to the date format you need.
Hope it helps.
Best, Sleepyhead
HI, i am facing same issue but my date format is | date:'MM/dd/yyyy'
Another aproach is to use
yourdate.getTime()
to convert the date-time to a timestamp and sort on that propierty that is now a number
@mauriciogracia. Your approach helped. Created a new column for formatting yourdate from string to number in the angular app.model.ts, then use the new column in html with order=='new field name'. it worked. hope it is helpful.
@langr is great to know that it has help you, your explanation will surely help other people with same issue.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Dates should be working find since 2.1.0
@VadimDez
I am still not able to get the orderBy to work with date. I am using 2.1.1
`<tr *ngFor="let booking of activeBookings">
`
This is what i am doing, pretty simple usage, also tried using moment date format. My date time looks like this "2020-06-20T12:00:00-03:00" or "Nov 11, 2020" when using moment.
I also tried putting my momentDatePipe before the orderBy and after with no difference. I also tried true and false for the second parameter.
Any thoughts?
@jcanning seems to be working fine https://stackblitz.com/edit/ngx-order-pipe-jnvcw4
Hi @VadimDez,
Thanks! At first this still didnt work for me but then I noticed i am actually putting the orderBy on the field not the *ngFor. That was such a silly mistake but it is all working as expected for sorting dates and using moment. This is a great easy to use plugin. Thanks for creating this!
Hi VadimDez,
Thank you so much for this awesome tool.
I am using Angular 5.2.0 and ngx-order-pipe: 2.0.1
The sort does not work for date
My displayed date is like below: {{ testDate | date:'d MMMM yyyy' }}
The real date format in JSON is like this: Tue Mar 20 14:15:23 MDT 2018
Can you please help? Thank you.