I'm trying to add a native filter for dates on a superset dashboard but i can't find a way to format these dates.
So I have two problems : i'd prefer to display 01/06/2023 rather than 2023-06-01 and 2023-01-01 appears with only the year displayed (2023)
I've tried timestamps and field in the db but it's the same
You can use DATETIME_FORMAT
(supported in some databases like
MySQL):
SELECT DATETIME_FORMAT(your_date_column, '%Y/%m/%d') AS formatted_date
FROM your_table;
Or TO_CHAR
(for PostgreSQL):
SELECT TO_CHAR(your_date_column, 'YYYY/MM/DD') AS formatted_date FROM
your_table;YYYY
Replace your_date_column
and your_table
with the actual column and table names in your database.
To display with only the year when the day and month are January 1st:
SELECT
CASE
WHEN EXTRACT(MONTH FROM your_date_column) = 1 AND EXTRACT(DAY FROM your_date_column) = 1
THEN TO_CHAR(your_date_column, 'YYYY')
ELSE TO_CHAR(your_date_column, 'YYYY/MM/DD')
END AS formatted_date
FROM your_table;