判断 节假日 终极解决方案(带五一 十一,端午节,春节,清明节)
2009-06-24 23:24
471 查看
if exists (select * from dbo.sysobjects where id = object_id(N'[tb_Holiday]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [tb_Holiday]
GO
create table tb_Holiday(id int IDENTITY(1,1) NOT NULL primary key clustered,HolidayDate smalldatetime,HolidayName nvarchar(50) not null,Holidayvalue bigint not null,Type char(1) not null)
Go
Insert into tb_Holiday(HolidayDate,HolidayName,Holidayvalue,Type)
select '2009-01-01','元旦',1,'1'
union all select '2009-01-02','元旦',1,'1'
union all select '2009-01-03','元旦',1,'1'
union all select '2009-01-04','公休(周末)',128,'0'
union all select '2009-01-25','春节',2,'1'
union all select '2009-01-26','春节',2,'1'
union all select '2009-01-27','春节',2,'1'
union all select '2009-01-28','春节',2,'1'
union all select '2009-01-29','春节',2,'1'
union all select '2009-01-30','春节',2,'1'
union all select '2009-01-31','春节',2,'1'
union all select '2009-01-24','公休(周末)',128,'0'
union all select '2009-02-01','春节',2,'0'
union all select '2009-04-04','清明节',4,'1'
union all select '2009-04-05','清明节',4,'1'
union all select '2009-04-06','清明节',4,'1'
union all select '2009-05-01','劳动节',8,'1'
union all select '2009-05-02','劳动节',8,'1'
union all select '2009-05-03','劳动节',8,'1'
union all select '2009-05-28','端午节',16,'1'
union all select '2009-05-29','端午节',16,'1'
union all select '2009-05-30','端午节',16,'1'
union all select '2009-05-31','公休(周末)',128,'0'
union all select '2009-10-01','国庆节、中秋节',32,'1'
union all select '2009-10-02','国庆节、中秋节',32,'1'
union all select '2009-10-03','国庆节、中秋节',32,'1'
union all select '2009-10-04','国庆节、中秋节',32,'1'
union all select '2009-10-05','国庆节、中秋节',32,'1'
union all select '2009-10-06','国庆节、中秋节',32,'1'
union all select '2009-10-07','国庆节、中秋节',32,'1'
union all select '2009-10-08','国庆节、中秋节',32,'1'
union all select '2009-09-27','公休(周末)',128,'0'
union all select '2009-10-10','公休(周末)',128,'0'
union all select '2010-01-01','元旦',1,'1'
union all select '2010-01-02','元旦',1,'1'
union all select '2010-01-03','元旦',1,'1'
select distinct(HolidayName) from tb_Holiday where HolidayDate >=convert(datetime,'2009-2-2') and HolidayDate <= convert(datetime,'2009-5-30') or Holidayvalue =128
CREATE FUNCTION [dbo].[fnCheckDate](@solarDay DATETIME)
RETURNS bigint AS
BEGIN
DECLARE @OUTPUTDATA Bigint --返回数值
SET @OUTPUTDATA = 0 --初始化为非假日
select @OUTPUTDATA=@OUTPUTDATA|Holidayvalue from tb_Holiday where Holidayvalue<>128 and HolidayDate=@solarDay
IF (@OUTPUTDATA = 0)
Begin
IF (@@DATEFIRST+DATEPART(Weekday,@solarDay)-1)%7 in(0,6) And not Exists(select * from tb_Holiday where HolidayDate=@solarDay and Type='0')
select @OUTPUTDATA = 128
End
Return @OUTPUTDATA
END
drop table [tb_Holiday]
GO
create table tb_Holiday(id int IDENTITY(1,1) NOT NULL primary key clustered,HolidayDate smalldatetime,HolidayName nvarchar(50) not null,Holidayvalue bigint not null,Type char(1) not null)
Go
Insert into tb_Holiday(HolidayDate,HolidayName,Holidayvalue,Type)
select '2009-01-01','元旦',1,'1'
union all select '2009-01-02','元旦',1,'1'
union all select '2009-01-03','元旦',1,'1'
union all select '2009-01-04','公休(周末)',128,'0'
union all select '2009-01-25','春节',2,'1'
union all select '2009-01-26','春节',2,'1'
union all select '2009-01-27','春节',2,'1'
union all select '2009-01-28','春节',2,'1'
union all select '2009-01-29','春节',2,'1'
union all select '2009-01-30','春节',2,'1'
union all select '2009-01-31','春节',2,'1'
union all select '2009-01-24','公休(周末)',128,'0'
union all select '2009-02-01','春节',2,'0'
union all select '2009-04-04','清明节',4,'1'
union all select '2009-04-05','清明节',4,'1'
union all select '2009-04-06','清明节',4,'1'
union all select '2009-05-01','劳动节',8,'1'
union all select '2009-05-02','劳动节',8,'1'
union all select '2009-05-03','劳动节',8,'1'
union all select '2009-05-28','端午节',16,'1'
union all select '2009-05-29','端午节',16,'1'
union all select '2009-05-30','端午节',16,'1'
union all select '2009-05-31','公休(周末)',128,'0'
union all select '2009-10-01','国庆节、中秋节',32,'1'
union all select '2009-10-02','国庆节、中秋节',32,'1'
union all select '2009-10-03','国庆节、中秋节',32,'1'
union all select '2009-10-04','国庆节、中秋节',32,'1'
union all select '2009-10-05','国庆节、中秋节',32,'1'
union all select '2009-10-06','国庆节、中秋节',32,'1'
union all select '2009-10-07','国庆节、中秋节',32,'1'
union all select '2009-10-08','国庆节、中秋节',32,'1'
union all select '2009-09-27','公休(周末)',128,'0'
union all select '2009-10-10','公休(周末)',128,'0'
union all select '2010-01-01','元旦',1,'1'
union all select '2010-01-02','元旦',1,'1'
union all select '2010-01-03','元旦',1,'1'
select distinct(HolidayName) from tb_Holiday where HolidayDate >=convert(datetime,'2009-2-2') and HolidayDate <= convert(datetime,'2009-5-30') or Holidayvalue =128
CREATE FUNCTION [dbo].[fnCheckDate](@solarDay DATETIME)
RETURNS bigint AS
BEGIN
DECLARE @OUTPUTDATA Bigint --返回数值
SET @OUTPUTDATA = 0 --初始化为非假日
select @OUTPUTDATA=@OUTPUTDATA|Holidayvalue from tb_Holiday where Holidayvalue<>128 and HolidayDate=@solarDay
IF (@OUTPUTDATA = 0)
Begin
IF (@@DATEFIRST+DATEPART(Weekday,@solarDay)-1)%7 in(0,6) And not Exists(select * from tb_Holiday where HolidayDate=@solarDay and Type='0')
select @OUTPUTDATA = 128
End
Return @OUTPUTDATA
END
相关文章推荐
- 2012年放假安排时间表,元旦、春节、清明、五一、端午节、中秋节、国庆节放假安排时间表
- sql 节假日判断(春节、中秋、国庆、周末等)
- sql 节假日判断(春节、中秋、国庆、周末等)
- js判断一个变量为空的终极解决方案
- sql 节假日判断(春节、中秋、国庆、周末等)
- 【JAVA应用】一种通过网页爬虫判断春节、端午节、中秋节等法定节假日休假时间段的方法
- 基于Java代码实现判断春节、端午节、中秋节等法定节假日的方法
- sql 节假日判断(春节、中秋、国庆、周末等)
- QT5 Failed to load platform plugin "windows" 终极解决方案 命令行问题
- Android大图片裁剪终极解决方案(中:从相册截图)
- Android studio 编译很慢的终极解决方案
- JS HTTP 请求终极解决方案 - fly.js
- vs2008 table div 无法全屏的终极解决方案
- ASP.net 2005 Treeview 无限分类非地递归终极解决方案
- 关于Anaroid模拟器不能上网终极解决方案
- 为什么Actor模型是高并发事务的终极解决方案
- android软键盘弹出引起的各种不适终极解决方案
- Bootstrap轮播插件中图片变形的终极解决方案 使用jqthumb.js
- MySQL乱码终极解决方案
- Nginx提示502和504错误的终极解决方案