with temp as(
select '2020-01-02' yyyymmdd from dual
union all select '2020-03-15' from dual
union all select '2020-04-30' from dual
union all select '2020-09-12' from dual
union all select '2020-12-05' from dual
)
select * from temp
위의 날짜중에서
예를 들어 오늘 오늘날짜(3월15일)를 기준으로 가장 가까운 날짜는 2020-3-17인데
저 값을 구할 방법이 있을까요?
Comment 1
-
처리짱
2020.03.20 17:12
with temp as(select '2020-01-02' yyyymmddunion all select '2020-03-15'union all select '2020-04-30'union all select '2020-09-12'union all select '2020-12-05')select top 1 * from temporder by ABS(DATEDIFF(day, yyyymmdd, GETDATE())) ASC