Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,455,373
Community Members
 
Community Events
175
Community Groups

How to sort date when its format is like '10 - Feb -2022‘?

The target date format is 11-Feb-2022. 

But when I use this format, the date sorting is based on number and then alphabet (believing it is a string now) . Let me show you the picture.

I change the date format into d M yy in table edit page in setting and then it looks like the picture. 

And one more thing : when the format is M - D -YYYY , there is 0 in front of some date cell, Please check the [Pre Date]. 

all data are from jira. 

Here is the JQL 

SELECT 'IMPORT',
     FORMATWIKI(SUM('ITEM'+"\n")) AS 'Item',
     FORMATWIKI(SUM( ’Date'+ "\n ")) as 'Date',
     FORMATWIKI(sum('Pre Date'+"\n" )) as 'Pre Date',
FROM (

       SELECT 'Import', 'Item' ,

                  FORMATDATE('Date') as 'Date',

                  FORMATDATE('Pre Date') as 'Pre Date'

     FROM T* ORDER BY 'Item' , 'Date' ASC

         ) T1
GROUP BY 'Item'

image.png

 

1 comment

Hi @CYH ,

You are right and the Date column is treated as a string data after the FORMATWIKI manipulations.

I'm not really sure what exactly you had into the original table coming from the Jira Issues macro, but I've created a regular Confluence table, copied your query with the ordering by 'Date' ASC and get the same result.

Fri 10-5.png

Fri 10-6.png

The simplest option is to use the second Table Transformer: leave all the data manipulations in the first one and use the second one only for sorting.

Fri 10-1.png

Fri 10-4.png

Now we see that the dates are sorted correctly.

And don't forget to choose the corresponding Date Format in the Table Transformer macro settings:

Fri 10-3.png

 

And as you use our Table Filter and Charts for Confluence app, note that recently we've released a new macro - Table Spreadsheet. Please check out new Excel functionality right in Confluence: the macro is available for Cloud and Server/DC.

Like # people like this

HI Katerina,

I try to use the second Table Transformer but it doesn't work. 

Here is the inside (The first one) Table   and the Date format in settings  is 'YYYY-MM-DD':image.png

Here is the outside table transformer:--the result of date format is the same 

and the date format in setting is d M yy (1 Apr 2022)image.png

 

Another Try:

Set first table date format as d M yy 

result : disorder sorting of Due Date

Continue to set second table date format as d M yy 

result :  disorder sorting of Due Date

 

 

Could you check which part I did wrong? 

The Date format inside the first Table Transformer macro settings is the result format that comes from the FORMATDATE function that you use in the first query.

In the first question you said that the desired output is 11-Feb-2022, so use the dd-M-yyyy format twice.

The first variant uses two different formats: at first you change the date to the YYYY-MM-DD and then sort these dates as d M yy.

The second variant seems better and should be working fine.

 

I also paid attention that you try to sort several dates inside one cell - this may be the problem. The Table Transformer macro works with tables as with SQL databases, I mean with cells, not with aggregated pivot tables (in my example I used non-grouped table).

Try to format your data, then sort the dates when they are still in separate cells and then group the already sorted fields by something.

I see. let me try to sort the date first and then group them. Will give you feedback later. Thanks a lot 

Hi Katerina 

your suggestion of " to format data, then sort the dates when they are still in separate cells and then group the already sorted fields by something " works so well ! 

I am stuck in group them first.

Thank you so much !

Comment

Log in or Sign up to comment
TAGS

Atlassian Community Events