Question

how to change date format to 'mm/dd/yyyy' from 'yyyy-mm-dd'

  • 20 May 2020
  • 4 replies
  • 1776 views

I am trying


dimension: tdate {

type: date

sql: DATE_FORMAT(${TABLE}.“TDATE”,’%m/%d/%Y’) ;;

}


but not getting output


4 replies

Userlevel 5
Badge

You cannot control the format of a type: date dimension.


Try with type: string, that should do the trick


It worked for me on Snowflake:


  dimension: date_format {
type: string
sql: to_char(${TABLE}.created_at, 'MM/DD/YYYY') ;;

This likely would suit your purpose:

https://help.looker.com/hc/en-us/articles/360023800253-Easy-Date-Formatting-with-Liquid

Userlevel 2

I would not recommend using the type: string method, as you lose the advantages that come with type: date dimensions (such as dimension fill and dynamic labels). Instead use the html tag to convert your date dimension into the format that you want.

 

dimension: tdate_formatted {
sql: ${TABLE}.“TDATE” ;;
html: {{ rendered_value | date: “%m/%d/%Y" }} ;;
}

Userlevel 1

i know this is an old thread but can we set the default date format for a dashboard filter to be mm/dd/yyyy instead of yyyy/mm/dd

Reply