Ticket #4729 (closed enhancement: wontfix)

Opened 4 years ago

Last modified 11 months ago

Sort as a date

Reported by: rennerocha Assigned to: doki_pen
Priority: normal Component: DateFieldPlugin
Severity: normal Keywords:
Cc: itamarost Trac Release: 0.11

Description

Actually, the fields are sorted as a 'text' field. It will be nice if we can sort the 'date' fields as a real date.

Attachments

Change History

(in reply to: ↑ description ; follow-up: ↓ 2 ) 04/17/09 10:53:12 changed by anonymous

Replying to rennerocha:

Actually, the fields are sorted as a 'text' field. It will be nice if we can sort the 'date' fields as a real date.

Workaround: use format=ymd. Sorting works well then.

(in reply to: ↑ 1 ) 04/17/09 14:53:12 changed by anonymous

Replying to anonymous:

Replying to rennerocha:

Actually, the fields are sorted as a 'text' field. It will be nice if we can sort the 'date' fields as a real date.

Workaround: use format=ymd. Sorting works well then.

Thanks! I am already using that. But here (in Brazil) it is uncommon the form 'ymd'. It will be better for the end users to be able to insert the data in 'dmy' form and have it sorted correctly.

(in reply to: ↑ description ) 10/21/09 19:42:36 changed by hju@jochenkuhl.de

Replying to rennerocha:

Actually, the fields are sorted as a 'text' field. It will be nice if we can sort the 'date' fields as a real date.

I faced the same problem in reports. Here is my solution: I transform the datestring to time in the sql-query of the reports!

SELECT ... cCur.value AS Current_Due, ...
FROM ticket t
LEFT OUTER JOIN ticket_custom cDue ON (t.id = cDue.ticket AND cDue.name = 'due_date')
... ORDER BY
strftime('%s',substr(cDue.value,7,4)||"-"||substr(cDue.value,4,2)||"-"||substr(cDue.value,1,2))

my custum ticket is named due_date.

By the way: you can filter tickets by comparing the Due date i.e. with the actual date.

... < strftime('%s',date('now'))

11/26/09 10:43:55 changed by terje

Here is micro (Trac) patch to enable sorting in custom query results. Postgres only + hardcoded to due_assign, due_close in DD-MM-YYYY format, I put it up so others have a place to start if interested:

Index: trac/ticket/query.py
===================================================================
--- trac/ticket/query.py        (revision 8858)
+++ trac/ticket/query.py        (working copy)
@@ -537,6 +537,10 @@
             #        one, if text, we do 'else'
             if name in ('id', 'time', 'changetime'):
                 sql.append("COALESCE(%s,0)=0%s," % (col, desc))
+            elif name in ('due_assign', 'due_close'):
+                # invert sort order
+                mydesc = desc!=' DESC' and ' DESC' or ''
+                sql.append("TO_TIMESTAMP(COALESCE(%s, '01-01-1970'), 'DD-MM-YYYY')%s," % (col, mydesc))
             else:
                 sql.append("COALESCE(%s,'')=''%s," % (col, desc))
             if name in enum_columns:

04/19/10 15:24:46 changed by doki_pen

  • owner changed from coderanger to doki_pen.

07/08/11 23:49:36 changed by rjollos

See also #8964.

12/25/11 21:33:09 changed by itamarost

  • cc set to itamarost.

07/09/12 22:06:38 changed by rjollos

  • status changed from new to closed.
  • resolution set to fixed.

Update on plugin development: It will not be the aim of DateFieldPlugin to support a true date type, rather, just provide a datepicker for input fields. See #8964 for more details. True date type support is coming to the Trac core in the near future (see t:#1942).

07/09/12 22:10:05 changed by rjollos

  • status changed from closed to reopened.
  • resolution deleted.

07/09/12 22:10:14 changed by rjollos

  • status changed from reopened to closed.
  • resolution set to wontfix.

Add/Change #4729 (Sort as a date)




Change Properties
Action