我一张表如下
年 天数(日期以天数记)
2001 1
2001 2
. .
. .
2001 364
2001 365
2002 1
2002 2
. .
. .
2002 364
2002 365
2003 1
2003 2
. .
. .
2003 364
2003 365如何使用Select * From 某表 WHERE 年份 天数
查询2001年第100天 到2002年 第300天的数据,同时又能查询同一年,比如2002年第20天到第80天的数据.
同时要考虑,不同年内 和 同一年内的情况!最终在dawugui(爱新觉罗.毓华)和xiaolinyouni(苦苦的潜行者) 的帮助下得到解决:解决方法如下:
if StartYaer=EndYaer then
//如果年份相等,只在年里选择天
Sql ="select * from "&CZNAMEFILE&" where [年份] = "&EndYaer&" and [天数] between "&StartDayNum&" and "&EndDayNum&""
else
//如果年份不等,只在联合查询天数
Sql ="select * from "&CZNAMEFILE&" where [年份]="&StartYaer&" and [天数]>"&StartDayNum&" union all select * from "&CZNAMEFILE&" where [年份]="&EndYaer&" and [天数]<="&EndDayNum&" union all select * from "&CZNAMEFILE&" where [年份]="&EndYaer&" and [天数]>"&StartDayNum&" and [天数]<="&EndDayNum&""
end if
不知道有那位高手能用一句查询语句表达???
年 天数(日期以天数记)
2001 1
2001 2
. .
. .
2001 364
2001 365
2002 1
2002 2
. .
. .
2002 364
2002 365
2003 1
2003 2
. .
. .
2003 364
2003 365如何使用Select * From 某表 WHERE 年份 天数
查询2001年第100天 到2002年 第300天的数据,同时又能查询同一年,比如2002年第20天到第80天的数据.
同时要考虑,不同年内 和 同一年内的情况!最终在dawugui(爱新觉罗.毓华)和xiaolinyouni(苦苦的潜行者) 的帮助下得到解决:解决方法如下:
if StartYaer=EndYaer then
//如果年份相等,只在年里选择天
Sql ="select * from "&CZNAMEFILE&" where [年份] = "&EndYaer&" and [天数] between "&StartDayNum&" and "&EndDayNum&""
else
//如果年份不等,只在联合查询天数
Sql ="select * from "&CZNAMEFILE&" where [年份]="&StartYaer&" and [天数]>"&StartDayNum&" union all select * from "&CZNAMEFILE&" where [年份]="&EndYaer&" and [天数]<="&EndDayNum&" union all select * from "&CZNAMEFILE&" where [年份]="&EndYaer&" and [天数]>"&StartDayNum&" and [天数]<="&EndDayNum&""
end if
不知道有那位高手能用一句查询语句表达???
datediff(dd,原时间,getdate()//当前系统时间),dd为天数
EndDate=Request("EndDate") //结束日期StartYear=left(StartDate,4) //开始年份
StartDateHead=StartYear & "-01-01" //开始年份的第一天
Startdaynum=datediff("D",StartDateHead,StartDate)//开始日期在本年的天数EndYear=left(EndDate,4) //结束年份
EndDateHead=EndYear & "-01-01" //结束年份的第一天
Enddaynum=datediff("D",EndDateHead,EndDate)//结束日期在本年的天数
//需求:
//当开始日期StartDate为2010-08-01,结束日期间为2010-09-10取数据库
//或者 当设开始日期StartDate为2010-08-01,结束日期为2011-02-10取数据库数据样式在1楼,不知道有那位高手能用一句查询语句表达???