且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

验证sql server中的日期

更新时间:2023-11-29 13:50:46

假设您在数据库中有以下数据)

来自:03-03-2016收件价:04-03-2016

然后你的查询就像是

Suppose You have following data in database)
From :03-03-2016 To:04-03-2016
Then your query will be like
IF EXISTS(SELECT * FROM WorkFromHome WHERE UserId=@Id AND ((@FromDate >= FromDate and ToDate) OR (@ToDate <= FromDate and ToDate)))
BEGIN
	 RAISERROR('Already Applied',16,1);
	 return;
END





因为它可以是fromdate本身,所以介于两者之间是行不通的。



如果你有进一步的询问,请告诉我。



As it can be the fromdate itself, so between won't work.

Let me know if you have further query.