Home | Print | Q/A | Guest | NewsLetter
Display context of search results Case-sensitive searching
FrontPageCSV파일로Export방법36계연애학평균AD에계정밀어넣기 › 날짜형데이터의BETWEEN
Database System
Data Warehouse
Data Analysis
Operating System
Open Source
Enterprise Architecture
Software Engineering
Process
Working Smart

SQL Server
PostgreSQL
Oracle
DB2
Teradata
MySQL
Performance Tuning
Programming

Link
Philosophy
Tools
Misc
Who?
_
_
SideBar Edit

Contents

1 소스


1 소스 #

create table #temp
(
	begin_dt datetime
,	end_dt datetime
)

insert #temp
select '2010-01-19 00:00:00.000', '2010-01-19 10:51:06.640'
union all
select '2010-01-18 10:51:06.640', '2010-01-18 11:51:06.640'
union all
select '2010-01-18 10:51:06.640', '2010-01-19 10:51:06.640'

--현재일이 20100118 라면.. 
select * from #temp
where 1=1
and begin_dt < '20100119'
and end_dt >= '20100118'

이렇게 날짜(DD)단위가 아닌 시/분/초 이하의 단위까지 연산을 해야 하는 경우 '20100118' between begin_dt and end_dt와 같이 조건을 걸면 20100118 날짜의 데이터를 모두 가져오지는 않는다. 놓치기 쉽다..

EditText|Print|FindPage|DeletePage|LikePages|http://www.databaser.net|last modified 2010-03-08 17:35:13