Opened 16 years ago
Closed 12 years ago
#4729 closed enhancement (wontfix)
Sort as a date
Reported by: | Renne | Owned by: | Robert Corsaro |
---|---|---|---|
Priority: | normal | Component: | DateFieldPlugin |
Severity: | normal | Keywords: | |
Cc: | Itamar Oren | 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 (0)
Change History (10)
comment:1 follow-up: 2 Changed 16 years ago by
comment:2 Changed 16 years ago by
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.
comment:3 Changed 15 years ago by
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'))
comment:4 Changed 15 years ago by
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:
-
trac/ticket/query.py
537 537 # one, if text, we do 'else' 538 538 if name in ('id', 'time', 'changetime'): 539 539 sql.append("COALESCE(%s,0)=0%s," % (col, desc)) 540 elif name in ('due_assign', 'due_close'): 541 # invert sort order 542 mydesc = desc!=' DESC' and ' DESC' or '' 543 sql.append("TO_TIMESTAMP(COALESCE(%s, '01-01-1970'), 'DD-MM-YYYY')%s," % (col, mydesc)) 540 544 else: 541 545 sql.append("COALESCE(%s,'')=''%s," % (col, desc)) 542 546 if name in enum_columns:
comment:5 Changed 15 years ago by
Owner: | changed from Noah Kantrowitz to Robert Corsaro |
---|
comment:7 Changed 13 years ago by
Cc: | Itamar Oren added; anonymous removed |
---|
comment:8 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
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).
comment:9 Changed 12 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:10 Changed 12 years ago by
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
Replying to rennerocha:
Workaround: use format=ymd. Sorting works well then.