Describe 각종날짜계산 here http://yangdb.tistory.com/entry/날짜-구하기 {{{ --지난달의 마지막날 구하기 select dateadd(ms,-3,DATEADD(mm,DATEDIFF(mm,0,getdate() ), 0)) --지난해의 마지막날 구하기 select dateadd(ms,-3,DATEADD(yy,DATEDIFF(yy,0,getdate() ), 0)) --현재달의첫째날구하기 select DATEADD(mm, DATEDIFF(mm,0,getdate()), 0) --현재달의 마지막날 구하기 select dateadd(ms,-3,DATEADD(mm,DATEDIFF(m,0,getdate() )+1, 0)) --현재해의마지막날구하기 select dateadd(ms,-3,DATEADD(yy,DATEDIFF(yy,0,getdate() )+1, 0)) --현재달의첫째주월요일구하기 select DATEADD(wk, DATEDIFF(wk,0, dateadd(dd,6-datepart(day,getdate()),getdate())), 0) --현재주의 월요일 구하기 select DATEADD(wk, DATEDIFF(wk,0,getdate()), 0) --현재해의 첫째날 구하기 select DATEADD(yy, DATEDIFF(yy,0,getdate()), 0) --현재분기의 첫째날 구하기 select DATEADD(qq, DATEDIFF(qq,0,getdate()), 0) --현재날의 자정 구하기 select DATEADD(dd, DATEDIFF(dd,0,getdate()), 0) }}} http://www.sqler.com/265068#2 convert 스타일 {{{ CONVERT(NVARCHAR, GETDATE(), 1) 10/14/10 CONVERT(NVARCHAR, GETDATE(), 2) 10.10.14 CONVERT(NVARCHAR, GETDATE(), 3) 14/10/10 CONVERT(NVARCHAR, GETDATE(), 4) 14.10.10 CONVERT(NVARCHAR, GETDATE(), 5) 14-10-10 CONVERT(NVARCHAR, GETDATE(), 6) 14 10 10 CONVERT(NVARCHAR, GETDATE(), 7) 10 14, 10 CONVERT(NVARCHAR, GETDATE(), 8) 14:35:29 CONVERT(NVARCHAR, GETDATE(), 9) 10 14 2010 2:35:29:247PM CONVERT(NVARCHAR, GETDATE(), 10) 10-14-10 CONVERT(NVARCHAR, GETDATE(), 11) 10/10/14 CONVERT(NVARCHAR, GETDATE(), 12) 101014 CONVERT(NVARCHAR, GETDATE(), 13) 14 10 2010 14:35:29:247 CONVERT(NVARCHAR, GETDATE(), 14) 14:35:29:247 CONVERT(NVARCHAR, GETDATE(), 20) 2010-10-14 14:35:29 CONVERT(NVARCHAR, GETDATE(), 21) 2010-10-14 14:35:29.247 CONVERT(NVARCHAR, GETDATE(), 22) 10/14/10 2:35:29 PM CONVERT(NVARCHAR, GETDATE(), 23) 2010-10-14 CONVERT(NVARCHAR, GETDATE(), 24) 14:35:29 CONVERT(NVARCHAR, GETDATE(), 25) 2010-10-14 14:35:29.247 CONVERT(NVARCHAR, GETDATE(), 100) 10 14 2010 2:35PM CONVERT(NVARCHAR, GETDATE(), 101) 10/14/2010 CONVERT(NVARCHAR, GETDATE(), 102) 2010.10.14 CONVERT(NVARCHAR, GETDATE(), 103) 14/10/2010 CONVERT(NVARCHAR, GETDATE(), 104) 14.10.2010 CONVERT(NVARCHAR, GETDATE(), 105) 14-10-2010 CONVERT(NVARCHAR, GETDATE(), 106) 14 10 2010 CONVERT(NVARCHAR, GETDATE(), 107) 10 14, 2010 CONVERT(NVARCHAR, GETDATE(), 108) 14:35:29 CONVERT(NVARCHAR, GETDATE(), 109) 10 14 2010 2:35:29:247PM CONVERT(NVARCHAR, GETDATE(), 110) 10-14-2010 CONVERT(NVARCHAR, GETDATE(), 111) 2010/10/14 CONVERT(NVARCHAR, GETDATE(), 112) 20101014 CONVERT(NVARCHAR, GETDATE(), 113) 14 10 2010 14:35:29:247 CONVERT(NVARCHAR, GETDATE(), 114) 14:35:29:247 CONVERT(NVARCHAR, GETDATE(), 120) 2010-10-14 14:35:29 CONVERT(NVARCHAR, GETDATE(), 121) 2010-10-14 14:35:29.247 CONVERT(NVARCHAR, GETDATE(), 126) 2010-10-14T14:35:29.247 CONVERT(NVARCHAR, GETDATE(), 127) 2010-10-14T14:35:29.247 CONVERT(NVARCHAR, GETDATE(), 130) 7 ذو القعدة 1431 2:35:29:247 CONVERT(NVARCHAR, GETDATE(), 131) 7/11/1431 2:35:29:247PM }}}