I want to write a dimension with adding text values and date with MM/DD/YYYY format
eg: Result for: 2022/11/05
dimension: resultfor {
type: string
sql: 'Result For : ' || ${admin_dt_date} ;;
html:{{ rendered_value | date: "%m/%d/%Y" }};;
}
Result is showing with the above dimenstion is like
“Result For : 2022-11-05” But I Need “Result For : 11/05/2022”
Solved! Go to Solution.
Shows error as below with the above syntax given by you…
The Amazon Redshift database encountered an error while running this query.
ERROR: column "%m/%d/%y" does not exist in table_name
----------
This is working fine>dimension: result_for_date { Type: string sql: 'Result For:' || to_char(${admin_dt_date}, 'MM/DD/YYYY') ;; }
That’s correct, you have to use the `SQL` syntax of the database engine your model is connected.
I used MySql syntax for this example.
What about using SQL to get the result already formatted from database?
dimension: resultfor {
type: string
sql: CONCAT( 'Result For : ', DATE_FORMAT( ${admin_dt_date}, "%m/%d/%Y" )) ;;
}
Shows error as below with the above syntax given by you…
The Amazon Redshift database encountered an error while running this query.
ERROR: column "%m/%d/%y" does not exist in table_name
----------
This is working fine>dimension: result_for_date { Type: string sql: 'Result For:' || to_char(${admin_dt_date}, 'MM/DD/YYYY') ;;
}
Shows error as below with the above syntax given by you…
The Amazon Redshift database encountered an error while running this query.
ERROR: column "%m/%d/%y" does not exist in table_name
----------
This is working fine>dimension: result_for_date { Type: string sql: 'Result For:' || to_char(${admin_dt_date}, 'MM/DD/YYYY') ;; }
That’s correct, you have to use the `SQL` syntax of the database engine your model is connected.
I used MySql syntax for this example.