Column Styles not reformatting dates from SQL Query...
Asked by Niall Poole:

Hi,

I'm using SQL to pull a list of milestones from a 3rd party system - the returned table has three columns - Project, Milestone, Date.

I using table excerpt to pull other tables from around confluence with project phase dates and trying to put the whole thing in a Gantt chart (Chart from Table macro).

Problem: The dates in the SQL query are in a different format to the dates in the other tables. The Gantt chart is showing the dates from the other tables, but ignoring the rows with the different date format. So I think I need to get all the dates in the same format and I don't have control of the other confluence pages so I'm looking at the SQL query...

The date format in the SQL table is yy-mm-dd (2022-11-01). The confluence tables use the date macro - I think the format is dd M yy (01 Nov 2022).

I've tried using column types and styles in the SQL Query macro but I can't seem to get it to do anything...

columnTypes = S, S, M

columnStyles = ,,MYYYY-MM-DD\~DDMMMYYYY

Am I using it wrong? Or is there a better way to do it?

Niall.


Answers:
author: Katerina Kovriga {Stiltsoft}
body: Hi [@Niall Poole](/t5/user/viewprofilepage/user-id/4796586) ,

As you've mentioned the [Chart from Table](https://docs.stiltsoft.com/display/public/TFAC/How+to+use+Chart+from+Table+macro?utm_source=atl_community&utm_medium=answer&utm_campaign=table-filter-traffic-sources&utm_vendorID=1216111) macro, I assume that you use our [Table Filter and Charts from Confluence](https://marketplace.atlassian.com/apps/27447/table-filter-and-charts-for-confluence?tab=overview&hosting=server&utm_source=atl_community&utm_medium=answer&utm_campaign=table-filter-traffic-sources&utm_vendorID=1216111) app.

So, to change the date format from the tables coming from Confluence, you may also use our [Table Transformer](https://docs.stiltsoft.com/display/public/TFAC/How+to+use+Table+Transformer+macro?utm_source=atl_community&utm_medium=answer&utm_campaign=table-filter-traffic-sources&utm_vendorID=1216111) macro.

For example, you wrap the source table in the Table Excerpt macro, reuse it on the required page with Gantt chart via the Table Excerpt Include macro, then use the Table Transformer macro on top to change date format and then continue building your chart.

The query for your case will be as following:

SELECT T1.'Phase', T1.'Date',  
T1.'Date'::Date-\>toLocaleDateString("sv-SE", {year:"numeric", month:"2-digit", day:"2-digit"}) AS 'Converted Date'  
FROM T\*

![Thu 6-1.png](https://community.atlassian.com/t5/image/serverpage/image-id/213876i09BA5D7FCD85D1DD/image-size/large?v=v2&px=999 "Thu 6-1.png")

Hope this helps your case.

comments: author: Niall Poole
body: Thanks [@Katerina Kovriga {Stiltsoft}](/t5/user/viewprofilepage/user-id/1464746)

That might work - I should get all the dates in the same format and then it's just the setting in the Chart from Table macro to tell it what format to expect if I remember rightly..., I'll give it a go.

Out of interest, is it possible to do the conversion the other way round? (Only because it would look nicer in the table :) and, in my scenario, fewer places to change it)

Niall.


author: Katerina Kovriga {Stiltsoft}
body: Yes, it will be even simpler than the first variant: go to the Settings tab of your Table Transformer macro and set the **d M yy** variant of the date format (it corresponds to your "28 Apr 2016" date picker, I assume).

Then use the following query:

SELECT T1.'Phase', FORMATDATE(T1.'Date') AS 'Converted Date'  
FROM T\*

The "2016-04-16" will turn as "28 Apr 2016".


author: Katerina Kovriga {Stiltsoft}
body: You may also use the FORMATDATE(T1.'Date', **"d M yy"** ) function with additional parameter **"d M yy** **"** that is your desired output to convert various date formats. This option is more easy-to-read than the first one.

And you may try to set the **yy-mm-dd** date format in the Chart from Table macro (at once, without any transformations) and the **d M yy**format will be understood automatically by the macro. But not vice versa or if you have other possible date formats in your source tables.


author: Niall Poole
body: Brilliant [@Katerina Kovriga {Stiltsoft}](/t5/user/viewprofilepage/user-id/1464746)

The FORMATDATE command has done the trick - I set the format in the macro, as you describe. rather than an extra parameter in the command.

I just need to get back to Alexey on this issue...

<https://community.atlassian.com/t5/Marketplace-Apps-Integrations/Stop-Events-showing-as-Milestones/qaq-p/2089460>

...and my Gannt chart will be perfect :)

Niall.


Tags: confluence-server

date

filter

gantt

server

sql

table

table-filter

table-filter-and-charts

table-transformer