* 오늘 쓴 글일 경우 시간표현, 어제까지 썼던 글은 날짜로 표현 *
1. DECODE문
select gdate, decode (to_char(gdate, 'yyyymmdd'), to_char(sysdate, 'yyyymmdd'),
to_char(gdate, 'hh24:mi:ss'),
to_char(gdate, 'yyyy-mm-dd')) as list_date
from board
gdate list_date
--------------------------------------
12/01/2006 11:17:53 11:17:53
12/01/2006 13:34:17 13:34:17
12/01/2006 11:18:00 11:18:00
12/01/2006 11:18:07 11:18:07
12/01/2006 11:18:38 11:18:38
12/01/2006 13:33:49 13:33:49
12/01/2006 11:17:25 11:17:25
12/01/2006 11:17:29 11:17:29
12/01/2006 13:33:53 13:33:53
12/01/2006 16:28:31 16:28:31
12/01/2006 15:09:14 15:09:14
12/01/2006 16:27:22 16:27:22
12/01/2006 15:16:31 15:16:31
12/01/2006 16:27:26 16:27:26
11/30/2006 16:44:44 2006-11-30
12/01/2006 16:28:38 16:28:38
--------------------------------------------------------------------------------------
2. CASE문
SELECT gdate, CASE to_char(gdate, 'yyyymmdd')
WHEN to_char(sysdate, 'yyyymmdd') THEN to_char(gdate, 'hh24:mi:ss')
ELSE to_char(gdate, 'yyyy-mm-dd')
END as list_date
FROM board
gdate list_date
-------------------------------------
12/01/2006 11:17:53 11:17:53
12/01/2006 13:34:17 13:34:17
12/01/2006 11:18:00 11:18:00
12/01/2006 11:18:07 11:18:07
12/01/2006 11:18:38 11:18:38
12/01/2006 13:33:49 13:33:49
12/01/2006 11:17:25 11:17:25
12/01/2006 11:17:29 11:17:29
12/01/2006 13:33:53 13:33:53
12/01/2006 16:28:31 16:28:31
12/01/2006 15:09:14 15:09:14
12/01/2006 16:27:22 16:27:22
12/01/2006 15:16:31 15:16:31
12/01/2006 16:27:26 16:27:26
11/30/2006 16:44:44 2006-11-30
12/01/2006 16:28:38 16:28:38
- 06년 12월 1일 20시 45분 -
댓글 없음:
댓글 쓰기