Date formatting

Nags Subramanian April 24, 2024

i have a source table like with values like this

023 Q1  31213 111
2023 Q3 1 22    5
2023 Q4      4 1115
2024 Q1  221 1 28
2024 Q22  14    7
2024 Q3    21   3
2024 Q4  310102201248
2025 Q11  86 21 440
2025 Q2    4 3  7
2025 Q3    6    6
2025 Q4   12 9 113
Total3182539461121163

i have written a table transformer macro with the query as

 

SELECT T1.'Quarter' as Quarter ,
case
when T1.'Quarter'="2023 Q1" then "Mar 31, 2023"
when T1.'Quarter'="2023 Q2" then "Jun 30, 2023"
when T1.'Quarter'="2023 Q3" then "Sep 30, 2023"
when T1.'Quarter'="2023 Q4" then "Dec 31, 2023"
when T1.'Quarter'="2024 Q1" then "Mar 31, 2024"
when T1.'Quarter'="2024 Q2" then "Jun 30, 2024"
when T1.'Quarter'="2024 Q3" then "Sep 30, 2024"
when T1.'Quarter'="2024 Q4" then "Dec 31, 2024"
when T1.'Quarter'="2025 Q1" then "Mar 31, 2025"
when T1.'Quarter'="2025 Q2" then "Jun 30, 2025"
when T1.'Quarter'="2025 Q3" then "Sep 30, 2025"
when T1.'Quarter'="2025 Q4" then "Dec 31, 2025"
end
as 'Quarter End Date',
T1.'Sum of Count AM' as 'AM',
T1.'Sum of Count CFO-GF' as'CFO-GF',
T1.'Sum of Count GCRG' as 'GCRG',
T1.'Sum of Count GWM' as 'GWM',
T1.'Sum of Count NCL' as 'NCL',
T1.'Sum of Count Other' as 'Other',
T1.'Sum of Count P&C & SB' as 'P&C & SB',
T1.'Sum of Count Treasury' as 'Treasury',
T1.'Sum of Count X-Divisional' as'X-divisional'
from T1

 

As a result i get the below table as result,

2023 Q11680217200000  31213 1
2023 Q31696028400000 1 22    
2023 Q41703980800000      4 11
2024 Q11711843200000  221 1 2
2024 Q217197020000002  14    
2024 Q31727650800000    21   
2024 Q41735603200000  3101022012
2025 Q117433756000001  86 21 4
2025 Q21751238000000    4 3  
2025 Q31759186800000    6    
2025 Q41767139200000   12 9 1
Total 3182539461121

 

Quarter End Date column , instead of a date, displays number like 1680217200000.

case
when T1.'Quarter'="2023 Q1" then "Mar 31, 2023"
when T1.'Quarter'="2023 Q2" then "Jun 30, 2023"
when T1.'Quarter'="2023 Q3" then "Sep 30, 2023"
when T1.'Quarter'="2023 Q4" then "Dec 31, 2023"
when T1.'Quarter'="2024 Q1" then "Mar 31, 2024"
when T1.'Quarter'="2024 Q2" then "Jun 30, 2024"
when T1.'Quarter'="2024 Q3" then "Sep 30, 2024"
when T1.'Quarter'="2024 Q4" then "Dec 31, 2024"
when T1.'Quarter'="2025 Q1" then "Mar 31, 2025"
when T1.'Quarter'="2025 Q2" then "Jun 30, 2025"
when T1.'Quarter'="2025 Q3" then "Sep 30, 2025"
when T1.'Quarter'="2025 Q4" then "Dec 31, 2025"
end
as 'Quarter End Date',

 

i have set the date format as M dd, yy in the setting on the table transformaer macro settings.

 

could you please let me know how to correct this?

 

thanks

 

1 answer

3 votes
Stiltsoft support
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 24, 2024

Hi @Nags Subramanian ,

You may use the FORMATDATE function in your query:

when T1.'Quarter'="2023 Q1" then FORMATDATE("Mar 31, 2023")

Nags Subramanian April 24, 2024

THANK YOU. i knew it would be as simple as that.

Like Stiltsoft support likes this
Stiltsoft support
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 24, 2024

Also as you set dates based not on some text condition (for example, if the project name is A, then Mar 31, 2023) but your conditions are based on real dates in a proper format, you may use a much more simple query:

SELECT *,
FORMATDATE(DATEADD(day, -1, DATEADD(quarter, 1, 'Quarter')), "M dd, yy")
AS 'Quarter End Date'
FROM T1

Wed 15-1.png

The date format in the Table Transformer macro settings should be set as yy Qi that corresponds to the "2023 Q1" format in your source table.

Like # people like this
Nags Subramanian April 24, 2024

oh this is much better, thank you.

Nags Subramanian April 24, 2024

sorry, i am using this but results look different. i have the date format as yy Qi too. what seems to be wrong please?

SELECT T1.'Quarter' as Quarter ,
FORMATDATE(DATEADD(day, -1, DATEADD(quarter, 1, T1.'Quarter')), "M dd, yy")
AS 'Quarter End Date',

 

Capture.PNG

Stiltsoft support
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 24, 2024

Seems that your version of the Table Filter, Charts & Spreadsheets for Confluence app may be an outdated one. Please ask your Confluence administrator to check and update if required.

The current version is 11.2.0.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events