Modify

Opened 6 years ago

Closed 2 years ago

#4729 closed enhancement (wontfix)

Sort as a date

Reported by: rennerocha Owned by: 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 (0)

Change History (10)

comment:1 in reply to: ↑ description ; follow-up: Changed 6 years ago 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.

comment:2 in reply to: ↑ 1 Changed 6 years ago 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.

comment:3 in reply to: ↑ description Changed 5 years ago by hju@…

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 5 years ago 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:

  • trac/ticket/query.py

     
    537537            #        one, if text, we do 'else'
    538538            if name in ('id', 'time', 'changetime'):
    539539                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))
    540544            else:
    541545                sql.append("COALESCE(%s,'')=''%s," % (col, desc))
    542546            if name in enum_columns:

comment:5 Changed 5 years ago by doki_pen

  • Owner changed from coderanger to doki_pen

comment:6 Changed 3 years ago by rjollos

See also #8964.

comment:7 Changed 3 years ago by itamarost

  • Cc itamarost added; anonymous removed

comment:8 Changed 2 years ago by rjollos

  • Resolution set to fixed
  • Status changed from new to 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 2 years ago by rjollos

  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:10 Changed 2 years ago by rjollos

  • Resolution set to wontfix
  • Status changed from reopened to closed

Add Comment

Modify Ticket

Action
as closed The owner will remain doki_pen.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.