以后地位:首页 > 建站常识 > 列表

asp完成按日期时候查问数据

点击: 次时候:2017/1/23关头词:上海网页建造 上海网站建造 网站优化
上一礼拜(七天以内):select * from art where [now] between dateadd("ww",-1,now()) and now()上一礼拜(上周一至周日):select * from art where [now] betwee
<a href=http://3djiangyin.com/tags/shanghaiwangzhanzhizuo/><strong>上海网站建造</strong></a>
上一礼拜(七天以内):select * from art where [now] between dateadd("ww",-1,now()) and now()上一礼拜(上周一至周日):select * from art where [now] between dateadd("d",-Weekday(Now())-5,now()) and dateadd("d",-Weekday(Now())+1,now())上一月(上月的明天至明天):select * from art where [now] between dateadd("m",-1,now()) and now()上一月(1号至最初一天):select * from art where [now] between dateserial(year(now),month(now())-1,1) and dateserial(year(now),month(now()),1-1)在ACCESS数据库中,日期时候的比拟操纵符首要有>= 、<=、=三个!但不能间接把比拟时候用这些操纵符相连!为了辨别时候范例和别的范例,ACCESS中在时候比拟时在时候两头要加上#!比方,要查问2007-1-1日到2007-7-2日之间的信息,SQL语句能够写成:Select * form table where datefield >=#2007-1-1# and datefield <=#2007-7-2#在asp法式中对应得SQL串为:exsql="select * form table where datefield >= # 2007-1-1 # and datefield<=# 2007-7-2 # "若是把查问的时候换成一个其余页面传来的变量的话,SQL串对应点窜成:exsql="select * from table where datefield>=#" &Begindate& "# and datefield<= #" &Enddate& "#" ,此中变量Begindate和Enddate别离是查问的肇端时候和竣事时候。列出某一天, 上一礼拜的数据:SELECT distinct dateandtime FROM ctdate_by_query_date WHERE dateandtime between ((#2006-5-15#+(Weekday(2006-5-15)-7))-6) and (#2006-5-15#-7)+Weekday(2006-5-15)sql="SELECT distinct dateandtime FROM ctarticle WHERE dateandtime between ((#"&date&"#+(Weekday("&date&")"&norp&"7))-6) and (#"&date&"#"&norp&"7)+Weekday("&date&")"查问一天, 所附属礼拜一切天数的数据:SELECT * FROM ctdate_by_query_date WHERE dateandtime between ((#2006-5-15#+Weekday(2006-5-15))-6) and #2006-5-15#+Weekday(2006-5-15)查问一个时候段 SELECT * FROM ctdate_by_query_date WHERE dateandtime between #2006-5-1# and #2006-5-30#列出差别年份的年份, 并且不要不异:select distinct year(dateandtime) from ctarticle成果如: Expr1000 2000 2003 2004 2005 2006列出某一天, 上一年的第一笔记录:SELECT top 1 dateandtime FROM ctarticle where year(dateandtime)=(2006)-1sql="SELECT top 1 dateandtime FROM ctarticle where year(dateandtime)=(year(#"&date&"#))"&norp列出某一年的数据:sql="select * from ctdate_by_query_date where year(dateandtime)="&year(rqqdt_)&" order by dateandtime desc" 查找上一月中的第一笔记录:SELECT top 1 dateandtime FROM ctarticle where year(dateandtime)=year(#2006-5-28#) and month(dateandtime)=month(#2006-5-28#)-1列出某一月的数据:sql="select * from ctdate_by_query_date where year(dateandtime)="&year(rqqdt_)&" and month(dateandtime)="&month(rqqdt_)&" order by dateandtime desc"列出某一日的数据:sql="select * from ctdate_by_query_date where dateandtime=#"&rqqdt_&"# order by a.articleid desc"列出当天的数据:sql="select * from ctdate_by_query_date where dateandtime=date() order by a.articleid desc"
预定建站
收费供给网站优化
支付关头词