예를 들어 유럽 사용자를 위한 Explore 및 대시보드를 만드는 경우 숫자로 된 모든 날짜는 일-월-연도 순서로 표시되어야 합니다. 예를 들어 2019년 6월 7일은 07/06/2019 또는 Jun 07, 2019 형식이어야 합니다. Looker의 기본 형식은 날짜를 2019-06-07로 렌더링합니다. DATE_FORMAT()과 같은 SQL 함수를 사용하여 날짜 형식을 변경할 수 있지만 모두 일반 SQL로 작성하고 싶지는 않을 수 있습니다.
html 매개변수에서 Liquid 사용
측정기준의 html 매개변수에서 Liquid 형식을 사용하여 유효한 날짜 형식을 사용하는 필드의 형식을 변경할 수 있습니다. Liquid는 유효한 날짜를 예상하므로 기존 측정기준 그룹의 기간을 사용하는 것이 가장 좋습니다. 주 또는 월 번호는 정수로 반환되므로 변경할 수 없습니다.
예를 들어 Looker의 기본 형식 2022-08-23 대신 Aug 23 22 형식으로 렌더링하도록 ${created_date}의 형식을 지정할 수 있습니다.
# The original dimension group - hidden so that users can only choose from the formatted dates date and week timeframes
dimension_group: created {
hidden: yes
type: time
timeframes: [
raw,
time,
date,
hour,
hour_of_day,
time_of_day,
week,
month,
quarter,
year
]
sql: ${TABLE}.created_at ;;
}
# The customized timeframes, organized in the Explore field picker under the group label Created date
dimension: date_formatted {
group_label: "Created date"
label: "Date"
type: date_raw
sql: ${created_date} ;;
html: {{ rendered_value | date: "%b %d, %y" }};;
}
dimension: week_formatted {
group_label: "Created date"
label: "Week"
type: date_raw
sql: ${created_week} ;;
html: {{ rendered_value | date: "Week %U (%b %d)" }};;
}
strftime Reference
다음 표에는 다양한 strftime 형식이 나와 있습니다. Looker에서 일부 형식은 예상대로 렌더링되지 않을 수 있습니다.
지정자
다음으로 교체됨
예시
%a
평일 약칭*
목
%A
평일 이름*
목요일
%b
월 이름 약어*
8월
%B
월 이름*
8월
%c
날짜 및 시간 표현*
2001년 8월 23일 목요일 14:55:02
%C
연도를 100으로 나누어 정수로 자른 것(00~99)
20
%d
월중 일, 0으로 채움(01~31)
23
%D
짧은 MM/DD/YY 날짜(%m/%d/%y에 해당)
08/23/01
%e
월중 일, 공백으로 채움 ( 1~31)
23
%F
짧은 YYYY-MM-DD 날짜, %Y-%m-%d에 해당
2001-08-23
%g
주 기준 연도, 마지막 두 자리(00~99)
1
%G
주 기반 연도
2001
%h
월 이름 약어*(%b와 동일)
8월
%H
24시간 형식의 시간(00~23)
14
%I
12시간 형식의 시간(01~12)
02
%j
연중 일(001~366)
235
%k
24시간 형식의 시간, 한 자리 숫자는 공백으로 시작(0~23)
14
%l
12시간 형식의 시간, 한 자리 숫자는 공백으로 시작(0~12)
2
%m
월을 십진수로 표현(01~12)
8
%M
분(00~59)
55
%n
줄바꿈 문자('\n')
%P
소문자 am 또는 pm 지정
pm
%r
12시간제 시간*
2:55:02 PM
%R
24시간 HH:MM 시간, %H:%M에 해당
14:55
%s
에포크, 즉 1970-01-01 00:00:00 +0000(UTC) 이후의 시간(초)
1566236649
%S
초(00~61)
2
%t
가로 탭 문자('\t')
%T
ISO 8601 시간 형식(HH:MM:SS), %H:%M:%S에 해당
14:55:02
%u
ISO 8601 요일을 숫자로 표현, 월요일이 1임(1~7)
4
%U
첫 번째 일요일이 첫 번째 주의 첫 번째 날인 주 번호(00~53)
33
%V
ISO 8601 주 번호(01~53)
34
%w
요일을 십진수로 표현, 일요일이 0임(0~6)
4
%W
첫 번째 월요일이 첫 번째 주의 첫 번째 날인 주 번호(00~53)
34
%x
날짜 표현*
08/23/01
%X
시간 표현*
14:55:02
%y
연도, 마지막 두 자리 숫자(00~99)
1
%Y
연도
2001
%z
UTC 시간대의 ISO 8601 오프셋(1분=1, 1시간=100), 시간대를 확인할 수 없는 경우 문자가 표시되지 않음
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-30(UTC)"],[],[],null,["# How to use Liquid to format dates\n\nIn some situations, you may want to change the way Looker formats dates.\n\n\nFor example, if you're building Explores and dashboards for users in Europe, any dates that are in an all-numeric format should appear in the order Day-Month-Year. For example, June 7th, 2019 should be formatted as `07/06/2019` or `Jun 07, 2019`. Looker's default format renders the date as `2019-06-07`. While you can use SQL functions like `DATE_FORMAT()` to change a date format, you may not want to write everything in plain SQL.\n\nUsing Liquid in the `html` parameter\n------------------------------------\n\n| **Note:** When [downloading content](/looker/docs/downloading), Liquid formatting applied in the [`html`](/looker/docs/reference/param-field-html) parameter is not applied to text-based download formats, such as TXT, CSV, Excel, or JSON.\n\n\nYou can use [Liquid formatting](https://shopify.github.io/liquid/filters/date/) in the [`html`](/looker/docs/reference/param-field-html) parameter of a dimension to change the format of any field that uses a valid date format. Since Liquid expects a valid date, it is best to use the timeframes from an existing dimension group. You can't change the week or month *numbers*, because those are returned as integers.\n| **Caution:** Liquid formatting is not supported for the [`month`](/looker/docs/reference/param-field-dimension-group#time_type) timeframe.\n\n\nFor example, you can format `${created_date}` to render as `Aug 23 22` instead of the Looker default `2022-08-23`: \n\n```\n\n dimension: date_formatted {\n sql: ${created_date} ;;\n html:{{ rendered_value | date: \"%b %d, %y\" }};;\n }\n\n\n```\n\n\nThe format for the string syntax `\"%b %d, %y\"` is the same as [`strftime`](http://strftime.net).\n\n\nBecause the `html` parameter uses Liquid formatting, the original value of the timeframe is not changed --- only the way that the value is rendered to the user. This ensures that the order in which dates appear in a query will not change.\n\n\nFollowing are some other examples you can use. The larger reference of available formats is at the bottom of this page.\n\nExample\n-------\n\n\nThe following example of an Explore query shows **Order Items Date** and **Orders Items Week** formatted differently and organized under a **Created date** group label to simulate a date dimension group in the Explore field picker.\n\n\nThe custom formatting shows users which date and which week number of the year correspond to the largest **Count of Items** values in descending order.\n\n\nSee the [`group_label` documentation page](/looker/docs/reference/param-field-group-label) to learn more about using the `group_label` parameter.\n\n\n### The LookML\n\n\nThe Explore example uses the following LookML: \n\n```\n\n\n# The original dimension group - hidden so that users can only choose from the formatted dates date and week timeframes\n dimension_group: created {\n hidden: yes\n type: time\n timeframes: [\n raw,\n time,\n date,\n hour,\n hour_of_day,\n time_of_day,\n week,\n month,\n quarter,\n year\n ]\n sql: ${TABLE}.created_at ;;\n }\n\n# The customized timeframes, organized in the Explore field picker under the group label Created date\n dimension: date_formatted {\n group_label: \"Created date\"\n label: \"Date\"\n type: date_raw\n sql: ${created_date} ;;\n html: {{ rendered_value | date: \"%b %d, %y\" }};;\n }\n\n dimension: week_formatted {\n group_label: \"Created date\"\n label: \"Week\"\n type: date_raw\n sql: ${created_week} ;;\n html: {{ rendered_value | date: \"Week %U (%b %d)\" }};;\n }\n\n\n```\n\n`strftime Reference`\n--------------------\n\n\nThe following table lists various `strftime` formats. Please note that not all formats may render as expected in Looker.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e"]]