Home > Database > Mysql Tutorial > sql 判断给定日期所在年是否闰年语句

sql 判断给定日期所在年是否闰年语句

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:47:40
Original
3915 people have browsed it

sql 判断给定日期所在年是否闰年语句
--根据全年总天数判断
declare @date datetime;
set @date = getdate()
select case datediff(day,dateadd(year,datediff(year,0,@date),0),dateadd(year,1+datediff(year,0,@date),0))
  when 365 then '平年' else '闰年' end
--根据二月天数判断
--给日期的上一年最后一天加2个月,即为当年2月最后一天
select case day(dateadd(month,2,dateadd(year,datediff(year,0,@date),-1))) when 28 then '平年' else '闰年' end
go

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
sql file
From 1970-01-01 08:00:00
0
0
0
php - Overhead of prepare vs sql?
From 1970-01-01 08:00:00
0
0
0
Print sql statement
From 1970-01-01 08:00:00
0
0
0
sql optimization or
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template