Modify

Opened 15 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 Ostricher 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 ; Changed 15 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 15 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 15 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 14 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 14 years ago by Robert Corsaro

Owner: changed from Noah Kantrowitz to Robert Corsaro

comment:6 Changed 13 years ago by Ryan J Ollos

See also #8964.

comment:7 Changed 12 years ago by Itamar Ostricher

Cc: Itamar Ostricher added; anonymous removed

comment:8 Changed 12 years ago by Ryan J Ollos

Resolution: fixed
Status: newclosed

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 Ryan J Ollos

Resolution: fixed
Status: closedreopened

comment:10 Changed 12 years ago by Ryan J Ollos

Resolution: wontfix
Status: reopenedclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Robert Corsaro.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.