Solved

Lobby: Extracted Month/Day not Sorting Correctly

  • 13 April 2021
  • 5 replies
  • 187 views

Userlevel 4
Badge +10
  • Sidekick (Customer)
  • 119 replies

We have a lobby by week that is not sorting the MM/DD date correctly since it treats it as text.

Can we:

1.) change it to a Date (didn’t work in the DataSource) so it sorts/orders correctly.

2.) Add a leading zero to single-digit months and days.

 

 

icon

Best answer by EntShehaM 13 April 2021, 21:43

View original

This topic has been closed for comments

5 replies

Userlevel 3
Badge +5

question is not quite clear though, is it related to date and month format fixing below queries may help you.

SELECT to_number(to_char(SYSDATE, 'W')) weeks FROM dual; --to get the current week of the month

SELECT to_number(to_char(SYSDATE, 'D')) days FROM dual; --to get the current day of the week

SELECT to_number(to_char(SYSDATE, 'DD')) to_day FROM dual; --to get the current date of the month

SELECT to_number(to_char(SYSDATE, 'MM')) to_month FROM dual; --to get the current month

SELECT to_char(SYSDATE, 'MM/DD') DD_MM FROM dual; --to get the current month/date 

hope above will helpful for your findings..

Userlevel 4
Badge +10

thx, I’ll try those.

 

To clarify, these two dates, 3/9 and 3/30, are sorting as 3/30, 3/9 instead of 3/9, 3/30 because it’s treating these as alphanumeric field type instead of Date.

Here’s the DataSource that shows it incorrectly sorted:

 

 

Userlevel 3
Badge +5

So basically you need to order your weeks accordingly. Try using Order By week ASC (ascending order may help in this situation).

Userlevel 4
Badge +10

thx! I’ll try that...

Userlevel 4
Badge +10

This worked perfectly! Thanks!!!

SELECT to_char(SYSDATE, 'MM/DD')