Oracle 11 : SQL : 246 바이트 (최소한 Java : P lol)
with d as(select to_date('&1','yyyy-mm-dd')s,to_date('&2','yyyy-mm-dd')e from dual),r as(select level-1 l from d connect by level<=e-s+1),x as(select s+l y,to_char(s+l,'yyyymmdd')w from d,r)select to_char(y,'yyyy-mm-dd')from x where w=reverse(w);
산출:
SQL> with d as(select to_date('&1','yyyy-mm-dd')s,to_date('&2','yyyy-mm-dd')e from dual),r as(select level-1 l from d connect by level<=e-s+1),x as(select s+l y,to_char(s+l,'yyyymmdd')w from d,r)select to_char(y,'yyyy-mm-dd')from x where w=reverse(w);
Enter value for 1: 2000-01-01
Enter value for 2: 2021-01-01
TO_CHAR(Y,
----------
2001-10-02
2010-01-02
2011-11-02
2020-02-02
SQL>
읽을 수있는 형식으로 :
with d as (select to_date('&1','yyyy-mm-dd') s,
to_date('&2','yyyy-mm-dd') e
from dual),
r as (select level-1 l
from d connect by level <= e-s+1),
x as (select s+l y, to_char(s+l,'yyyymmdd') w
from d,r)
select to_char(y,'yyyy-mm-dd')
from x
where w=reverse(w);
설명 :
d: get input for start/end
r: generate rows needed, 1 per day.
x: calculate the actual dates, and convert them to a minimal string.
final: use REVERSE function to verify the palindroms, return in proper format.
오늘 REVERSE 기능에 대해 배웠습니다 :)
DATE
을 피하고to_date()
아니면 덜 golfable을 사용할 필요가VARCHAR2
?