SQL 生成公曆和農曆對照數據續--创建萬年曆查找各種周期性節日數據
1 ---sql server 2005 測試 塗聚文 捷為工作室,締友計算機信息技術有限公司 2 ---查找公曆節日 3 --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' 4 select * from GoodDaysList 5 6 declare @setDate datetime,@year int,@month int,@day int,@weeks int,@weekday int,@GooddayUidKey Uniqueidentifier 7 set @setDate='2012-12-01' --設置現在的日期 8 set @year=Year(@setDate) 9 set @month=Month(@setDate) 10 set @day=DAy(@setDate) 11 set @weeks=DAy(@setDate) 12 set @GooddayUidKey='D9C5D984-6AEB-4EE4-B332-82F7E878D539' 13 select @year as '日',@month as '月',@day as '日' 14 15 select (@year-GooddayStaryear) as Gyear,GooddayContent from GoodDaysList where @year>=GooddayStaryear and GooddayStarmoth=@month and GooddayStardayorWeek=@weeks and GooddayUidKey=@GooddayUidKey 16 17 18 19 20 21 22 ---查找農日節日 測試 塗聚文 捷為工作室,締友計算機信息技術有限公司 23 ---1700年之前的节日需要用sql server 2008之後版本才行,Access 也行 24 select dbo.fn_GetLunarNumber('2012-06-23') 25 --農曆查公曆 26 select dbo.fn_GetDate('2012-05-05') 27 28 select * from dbo.GoodDayClass 29 30 declare @setDate datetime,@Lunaryear int,@Lunarmonth int,@Lunarday int,@weeks int,@weekday int,@GooddayUidKey Uniqueidentifier,@LunarDate datetime 31 set @setDate='2012-06-23' --設置現在的公曆日期 32 select @LunarDate=dbo.fn_GetLunarNumber(@setDate) 33 set @Lunaryear=Year(@LunarDate) 34 set @Lunarmonth=Month(@LunarDate) 35 set @Lunarday=DAy(@LunarDate) 36 set @weeks=DAy(@LunarDate) 37 set @GooddayUidKey='F25835BF-3918-4201-BB8D-BD82F737EF8A' 38 select @LunarDate as '農日日期',@Lunaryear as '農曆年',@Lunarmonth as '農曆月',@Lunarday as '農曆日' 39 select (@Lunaryear-GooddayStaryear) as Gyear,GooddayContent from GoodDaysList where @Lunaryear>=GooddayStaryear and GooddayStarmoth=@Lunarmonth and GooddayStardayorWeek=@weeks and GooddayUidKey=@GooddayUidKey 40 41 42 ---查找周節日 43 44 declare @setDate datetime,@year int,@month int,@day int,@weeks int,@weekday int,@GooddayUidKey Uniqueidentifier,@weekdayname varchar(10) 45 set @setDate='2012-05-06' --設置現在的日期 46 set @year=Year(@setDate) 47 set @month=Month(@setDate) 48 set @day=DAy(@setDate) 49 select @weeks=DATEPART(WEEK,@setDate)-DATEPART(WEEK,DATEADD(MONTH,DATEDIFF(MONTH,0,@setDate),0))+1 --月中周幾 50 select @weekday=DATEPART(weekday,@setDate) --周幾(0星期天,1星期一,2星期二) 51 select @weekdayname=DATENAME(weekday,@setDate) --周幾 52 set @GooddayUidKey='D9C5D984-6AEB-4EE4-B332-82F7E878D539' 53 select @year as '年',@month as '月',@weeks as '月中第幾周',@weekday as '周幾',@weekdayname as '周幾' 54 select (@year-GooddayStaryear) as Gyear,GooddayContent from GoodDaysList where @year>=GooddayStaryear and GooddayStarmoth=@month and GooddayStardayorWeek=@weeks and GooddayWeekdays=@weekday and GooddayUidKey=@GooddayUidKey 55 56 57 --查找年中第多少日的節日(如程序員節) 其它節日在此略
web demo: http://www.dusystem.com/Calendar.aspx
哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
2010-09-21 Csharp,Javascript 获取显示器的大小的几种方式
2009-09-21 谷歌地图API学习