Print Thread
Date Sort is wrong
#64209 09/07/22 02:23 PM
Joined: Mar 2019
Posts: 7
B
Member
OP Offline
Member
B
Joined: Mar 2019
Posts: 7
Hello,
if i want sort a date the Developer sorted it wrong, Only the day is correctly sorted bur not the moth.
What can I do, that the Developer sort the Date correctly?

Attached Files
Oracle.jpg (14.76 KB, 55 downloads)
Re: Date Sort is wrong
Baila_me #64210 09/07/22 03:58 PM
Joined: May 2015
Posts: 37
M
Member
Offline
Member
M
Joined: May 2015
Posts: 37
I'm guessing that you are converting a date to a string, in which case PL/SQL is sorting it (correctly) as a string.

e.g.1:

SELECT TO_CHAR(<DATE COLUMN>, 'dd.mm.yyyy') FROM <TABLE>;

The above would give the sort order and format that your screenshot shows.

e.g.2:

SELECT TO_DATE(TO_CHAR(<DATE COLUMN>, 'dd.mm.yyyy'), 'dd.mm.yyyy') FROM <TABLE> ;

The above (fairly nonsensical SQL) would tell PL/SQL Developer to treat it like it a date, and therefore sort it like a date.

-mobailey

Re: Date Sort is wrong
Baila_me #64211 09/07/22 09:08 PM
Joined: Jun 2015
Posts: 72
Russia
L
Member
Offline
Member
L
Joined: Jun 2015
Posts: 72
Russia
Also, PLSD have a "Date fields to_char" option. Check it out.

Re: Date Sort is wrong
Baila_me #64216 09/09/22 08:01 PM
Joined: Sep 2003
Posts: 387
London, UK
Member
Offline
Member
Joined: Sep 2003
Posts: 387
London, UK
What is the datatype of LIEF_DAT? If it's a string, it's correctly sorted. I've never known PL/SQL Developer to have a problem sorting actual dates.

Re: Date Sort is wrong
Baila_me #64217 09/11/22 03:15 PM
Joined: Mar 2019
Posts: 7
B
Member
OP Offline
Member
B
Joined: Mar 2019
Posts: 7
Lief_Dat is datatype Timestamp

Re: Date Sort is wrong
Baila_me #64218 09/11/22 03:39 PM
Joined: Mar 2019
Posts: 7
B
Member
OP Offline
Member
B
Joined: Mar 2019
Posts: 7
now i could more Details. if i sort the timestamp with order by then it is sorted correctly. But if i sort with the button at the columns then the PL/SQL Developer sorted wrong. What can i do? The funtion date to_char is disabled

Attached Files
sort.jpg (33.01 KB, 35 downloads)
Re: Date Sort is wrong
Baila_me #64230 09/15/22 01:52 PM
Joined: Mar 2019
Posts: 7
B
Member
OP Offline
Member
B
Joined: Mar 2019
Posts: 7
anyone a idea?

Re: Date Sort is wrong
Baila_me #64235 09/16/22 01:22 PM
Joined: Jan 2006
Posts: 39
J
Member
Offline
Member
J
Joined: Jan 2006
Posts: 39
Create a scenario that can reproduced by others. By that I mean, create a new table, insert some rows (say 4), write the SQL statement that reproduces the sorting issues you are seeing and share that with everyone here. This means you will have a CREATE TABLE statement, x number of INSERT statements, and a SELECT statement to share. Also include your version of PSD. From there, people can confirm whether they can reproduce the issue or not. So far you've provided the result, but nothing we can use to actually see or reproduce what you are doing.

Re: Date Sort is wrong
Baila_me #64240 09/23/22 09:29 AM
Joined: Mar 2007
Posts: 110
Hazerswoude-Dorp, NL
Member
Offline
Member
Joined: Mar 2007
Posts: 110
Hazerswoude-Dorp, NL
When sorting using the sort buttons in the sql window results:
In the configuration panel it is possible to set a date format for the date(user interface - nls_options - date). When set to YY-MM-DD a date column can be sorted using the sort buttons in the sql window results. For timestamp fields this format can not be set and sorting using the sort buttons sorts alphabetically as far as I can see. I have the number fields to char and date fields to char options deselected.

Sorting on date, time, timestamp, guid and number etc can best be done using the order by in the select of course.( btw when sorting on guid, make sure the guid is generated from the same source(before insert row trigger fi), else one may have unexpected results. Don't know yet how a database migration will effect the guid sort order.


Certainty of death, small chance of succes,
What are we waiting for... (Gimly)

Moderated by  support 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 7.1.33 Page Time: 0.169s Queries: 16 (0.115s) Memory: 2.5351 MB (Peak: 3.0417 MB) Data Comp: Off Server Time: 2024-05-19 16:56:25 UTC
Valid HTML 5 and Valid CSS