티스토리 뷰

728x90
반응형
declare @StartDate datetime
		, @EndDate datetime

set @start_date = cast(@start_date as date)
set @end_date = dateadd(day, 1, cast(@end_date as date))
set @end_date = dateadd(millisecond, -3, @end_date)

select @StartDate, @EndDate

dateadd 방식

declare @start_date datetime = '2019-08-29'

         , @end_date datetime = '2019-08-29'

 

select *

from a

where dateColumn between @start_date and DATEADD(MILLISECOND, -3, DATEADD(DAY, 1, @end_date))

 

declare @today datetime = convert(varchar(10), getdate(), 121)

where wi.in_date > dateadd(day, -60, @today) and  wi.in_date <= dateadd(day, -30, @today)

 

convert 방식

select 
COUNT(*) as [count]
from yourTableName with(nolock) 
where use_yn='Y'
and cust_no = @cust_no
and pl_cd  = @pl_cd
and convert(varchar(10), reg_dt, 112) between '20190630' and '20190630'

 

 

 

 

 

 

728x90
반응형