- 당일 조회
${COLUMN} = TO_CHAR(CURRENT_DATE,'YYYYMMDD')
- 주간 조회
${COLUMN} BETWEEN TO_CHAR(date_trunc('WEEK', CURRENT_DATE),'YYYYMMDD') and TO_CHAR((date_trunc('WEEK', CURRENT_DATE) + INTERVAL '6 day'),'YYYYMMDD')
- 월간 조회
${COLUMN} BETWEEN TO_CHAR(date_trunc('MONTH', CURRENT_DATE),'YYYYMMDD') and TO_CHAR((date_trunc('MONTH', CURRENT_DATE) + INTERVAL '1 MONTH - 1 day'),'YYYYMMDD')
- 연간 조회
${COLUMN} BETWEEN TO_CHAR(date_trunc('YEAR', CURRENT_DATE),'YYYYMMDD') and TO_CHAR((date_trunc('YEAR', CURRENT_DATE) + INTERVAL '1 YEAR - 1 day'),'YYYYMMDD')
728x90
'DB > PostgreSQL' 카테고리의 다른 글
[Postgresql] 영업일(business day)구하기 (1) | 2023.11.22 |
---|---|
[PostgreSQL] Update Join (0) | 2023.01.05 |
[PostgreSQL] DELETE JOIN (0) | 2022.09.15 |
[PostgreSQL] 날짜/시간 관련 함수 1 (2) | 2022.09.14 |
[postgreSql] GROUPING SETS/ROLLUP (0) | 2022.05.24 |