ITPub博客

首页 > Linux操作系统 > Linux操作系统 > SQL 生成公曆和農曆對照數據續--创建萬年曆查找各種周期性節日數據

SQL 生成公曆和農曆對照數據續--创建萬年曆查找各種周期性節日數據

原创 Linux操作系统 作者:geovindu 时间:2012-09-25 18:20:18 0 删除 编辑

---sql server 2005  測試 塗聚文 捷為工作室,締友計算機信息技術有限公司
 ---查找公曆節日
 --select (@year-GooddayStaryear) as Gyear,GooddayContent from GoodDaysList where @year>=GooddayStaryear and GooddayStarmoth=@month and GooddayStardayorWeek=@week and GooddayWeekdays=@Day  and GooddayUidKey='F0FAFC87-F492-455F-B56E-358917658B6E'
 select * from GoodDaysList
 
 declare @setDate datetime,@year int,@month int,@day int,@weeks int,@weekday int,@GooddayUidKey Uniqueidentifier
 set @setDate='2012-12-01' --設置現在的日期
 set @year=Year(@setDate)
 set @month=Month(@setDate)
 set @day=DAy(@setDate)
 set @weeks=DAy(@setDate)
 set @GooddayUidKey='D9C5D984-6AEB-4EE4-B332-82F7E878D539'
 select @year as '日',@month as '月',@day as '日'
 
 select (@year-GooddayStaryear) as Gyear,GooddayContent from GoodDaysList where @year>=GooddayStaryear and GooddayStarmoth=@month and GooddayStardayorWeek=@weeks and GooddayUidKey=@GooddayUidKey
 
 
 
 
 
 
 ---查找農日節日 測試 塗聚文 捷為工作室,締友計算機信息技術有限公司
 ---1700年之前的节日需要用sql server 2008之後版本才行,Access 也行
 select  dbo.fn_GetLunarNumber('2012-06-23')
 --農曆查公曆
 select dbo.fn_GetDate('2012-05-05')
 
  select * from dbo.GoodDayClass
 
 declare @setDate datetime,@Lunaryear int,@Lunarmonth int,@Lunarday int,@weeks int,@weekday int,@GooddayUidKey Uniqueidentifier,@LunarDate datetime
 set @setDate='2012-06-23' --設置現在的公曆日期
 select @LunarDate=dbo.fn_GetLunarNumber(@setDate)
 set @Lunaryear=Year(@LunarDate)
 set @Lunarmonth=Month(@LunarDate)
 set @Lunarday=DAy(@LunarDate)
 set @weeks=DAy(@LunarDate)
 set @GooddayUidKey='F25835BF-3918-4201-BB8D-BD82F737EF8A'
 select @LunarDate as '農日日期',@Lunaryear as '農曆年',@Lunarmonth as '農曆月',@Lunarday as '農曆日'
 select (@Lunaryear-GooddayStaryear) as Gyear,GooddayContent from GoodDaysList where @Lunaryear>=GooddayStaryear and GooddayStarmoth=@Lunarmonth and GooddayStardayorWeek=@weeks and GooddayUidKey=@GooddayUidKey
 
 
 ---查找周節日
 
 declare @setDate datetime,@year int,@month int,@day int,@weeks int,@weekday int,@GooddayUidKey Uniqueidentifier,@weekdayname varchar(10)
 set @setDate='2012-05-06' --設置現在的日期
 set @year=Year(@setDate)
 set @month=Month(@setDate)
 set @day=DAy(@setDate)
 select @weeks=DATEPART(WEEK,@setDate)-DATEPART(WEEK,DATEADD(MONTH,DATEDIFF(MONTH,0,@setDate),0))+1  --月中周幾
 select @weekday=DATEPART(weekday,@setDate) --周幾(0星期天,1星期一,2星期二)
 select @weekdayname=DATENAME(weekday,@setDate) --周幾
 set @GooddayUidKey='D9C5D984-6AEB-4EE4-B332-82F7E878D539'
 select @year as '年',@month as '月',@weeks as '月中第幾周',@weekday as '周幾',@weekdayname as '周幾'
 select (@year-GooddayStaryear) as Gyear,GooddayContent from GoodDaysList where @year>=GooddayStaryear and GooddayStarmoth=@month and GooddayStardayorWeek=@weeks and GooddayWeekdays=@weekday and GooddayUidKey=@GooddayUidKey
 
 
 --查找年中第多少日的節日(如程序員節) 其它節日在此略

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/682938/viewspace-745048/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2012-09-25

  • 博文量
    1
  • 访问量
    2083