不太明白ls意思,
你的联合查询可以查到前五天得数据了select * from
(
select * from "表1" union select * from "表2" union select * from "表3" union select * from "表4" union select * from "表5"
)a也可以建view 再查
你的联合查询可以查到前五天得数据了select * from
(
select * from "表1" union select * from "表2" union select * from "表3" union select * from "表4" union select * from "表5"
)a也可以建view 再查
解决方案 »
- 一个关于javascript字符串转换为日期的函数,希望对您有所帮助
- asp三元表达式
- orm问题
- asp.net 如何获取服务器上指定文件后获取文件的以下信息,请看~~~
- 怎样让TextBox在火狐下也能触发Changed事件
- 【急】treeview,前面有checkbox,如果点击button,获得选中值?
- right函数为什么会出错
- 高手请留步,帮我解决下麻烦撒!!!
- 如果在IE中使用脚本直接打印
- treeview,如何展开所有节点,一定要用js做,第一层老是打不开?
- 求助一份简单的聊天室asp代码
- *********************请教一个xslt的问题**********************
依次类推就可以啦
go
insert s20080101 select 1
gocreate table s20080102(id int)
go
insert s20080102 select 5
gocreate table s20080105(id int)
go
insert s20080105 select 101
godeclare @s varchar(8000)
select @s=isnull(@s+' union all select * from ','select * from ') + name from sysobjects where xtype='u' and isdate(stuff(name,1,1,''))=1exec(@s)
/*
id
1
5
101*/
go
drop table s20080101,s20080102,s20080105
go
go
insert s20080101 select 1
gocreate table s20080102(id int)
go
insert s20080102 select 5
gocreate table s20080105(id int)
go
insert s20080105 select 101
go--以下三表有效
create table s20080401(id int)
go
insert s20080401 select 401
go
create table s20080402(id int)
go
insert s20080402 select 402
gocreate table s20080403(id int)
go
insert s20080403 select 403
go
declare @s varchar(8000)
select @s=isnull(@s+' union all select * from ','select * from ') + name
from sysobjects where xtype='u'
and case when isdate(stuff(name,1,1,''))=1 then
datediff(dd,stuff(name,1,1,''),getdate())
else 5
end
between 0 and 4exec(@s)
/*
401
402
403
*/
go
drop table s20080101,s20080102,s20080105,s20080401,s20080402,s20080403
go
//当前输入的日期
System.DateTime time = System.DateTime.ParseExact(Ddlyear.SelectedItem.Text + Ddlmonth.SelectedItem.Text + Ddlday.SelectedItem.Text, "yyyyMMdd", null);
System.DateTime time1 = System.DateTime.Parse(time.ToString());
string fbsj = time1.ToString("yyyyMMdd");
//合成当前日期库
string fbsja = "s" + fbsj;
//合成当前日期前一天库
int fbsjb = Convert.ToInt32(fbsj) -1;
string fbsjbb = "s" + fbsjb;
//合成当前日期前两天库
int fbsjc = Convert.ToInt32(fbsj) - 2;
string fbsjcc = "s" + fbsjc;
//合成当前日期前三天库
int fbsjd = Convert.ToInt32(fbsj) - 3;
string fbsjdd = "s" + fbsjd;
//合成当前日期前四天库但有个问题就是如果当前日期是20080401时,合成当前日期前一天库就不是20080331了
System.DateTime time2=time1.AddDays(-1);//前一天,其他類推
'S'+replace(convert(varchar(10),getdate(),20),'-','') --S20080403'S'+replace(convert(varchar(10),dateadd(day,-1,getdate()),20),'-','') --S20080402'S'+replace(convert(varchar(10),dateadd(day,-2,getdate()),20),'-','') --S20080401'S'+replace(convert(varchar(10),dateadd(day,-3,getdate()),20),'-','') --S20080331'S'+replace(convert(varchar(10),dateadd(day,-4,getdate()),20),'-','') --S20080330
convert(varchar(10),getdate(),120) 得到 20080403varchar转datetime
datediff(dd,'20080403',getdate())
自己会隐式转换的。
我上面打错了,要得到 yyyyMMdd 使用112编码。select convert(varchar(8),getdate(),112)
你应该到sql的论坛去问
那里知道做的人比较多.