declare @thisDate datetime
set @thisDate='2012-08-24 10:37:48.293'
select (5)num,('add day 5')'init',dateadd(d,5,@thisDate)'after_add' union
select (7),('add month 5'),dateadd(mm,5,@thisDate) union
select (8),('add quarter 5'),dateadd(qq,5,@thisDate) union
select (9),('add year 5'),dateadd(yy,5,@thisDate) union
select (6),('add week 5'),dateadd(wk,5,@thisDate) union
select (4),('add hour 5'),dateadd(hh,5,@thisDate) union
select (3),('add minute 5'),dateadd(mi,5,@thisDate) union
select (2),('add second 5'),dateadd(ss,5,@thisDate) union
select (1),('add mili second 5'),dateadd(ms,5,@thisDate)
order by num asc
#Results:
num init after_add
1 add mili second 5 2012-08-24 10:37:48.300
2 add second 5 2012-08-24 10:37:53.293
3 add minute 5 2012-08-24 10:42:48.293
4 add hour 5 2012-08-24 15:37:48.293
5 add day 5 2012-08-29 10:37:48.293
6 add week 5 2012-09-28 10:37:48.293
7 add month 5 2013-01-24 10:37:48.293
8 add quarter 5 2013-11-24 10:37:48.293
9 add year 5 2017-08-24 10:37:48.293
Tidak ada komentar:
Posting Komentar