Comparing 2 dates
I have a table like this
CREATE TABLE tbl_CustMaster
(
CustID BIGINT IDENTITY(1,1)
CustName VARCHAR(100),
JoinDate DateTime,
EndDate DateTime
)
Now I want to run a query in which I want to extract custID which lies between JoinDate and EndDate. Can someone help me in doing this??
# 1 Re: Comparing 2 dates
You mean like this?
-- Select customers who joined and ended anywhere between
-- 2007-05-01 and 2007-12-01 (inclusive.)
SELECT CustID
FROM tbl_CustMaster
WHERE JoinDate >= '2007-05-01' AND EndDate < '2007-12-02';
# 3 Re: Comparing 2 dates
I have a table like this
CREATE TABLE tbl_CustMaster
(
CustID BIGINT IDENTITY(1,1)
CustName VARCHAR(100),
JoinDate DateTime,
EndDate DateTime
)
Now I want to run a query in which I want to extract custID which lies between JoinDate and EndDate. Can someone help me in doing this??
SELECT CustID
FROM tbl_CustMaster
WHERE JoinDate >= '2007-05-01' AND EndDate < '2007-12-02';
# 4 Re: Comparing 2 dates
SELECT CustID
FROM tbl_CustMaster
WHERE JoinDate >= '2007-05-01' AND EndDate < '2007-12-02';
Isnt that exactly what Andreas said? Because it is essentially a direct copy of Andreas' post it can be regarded as spam and I'll remove it in 3 days, unless you choose to return and edit it to offer some different advice.. (like BETWEEN, maybe? ;) hint hint)
cjard at 2007-11-9 13:48:33 >
