早教吧作业答案频道 -->英语-->
SQL日期参数加具体钟点时间如何表示我想界定一个starttime>某一天某一个时间比如说starttime>2010/08/1117:30:00可以表示如果把日期换成参数该怎么表示starttime>@starttime17:30:00类似的?如何做是
题目详情
SQL 日期参数 加 具体钟点时间 如何表示
我想界定一个 starttime>某一天 某一个时间
比如说starttime>2010/08/11 17:30:00 可以表示
如果把日期换成参数该怎么表示
starttime>@starttime 17:30:00
类似的?如何做
是在sql server 2005环境中
说具体一些吧
select a.DNIS,count(*) as total from dbo.Call a where a.dnis=@dnis
and a.BeginTime between @starttime and @endtime
group by a.DNIS
这段文字 我想加个条件 就是begintime 大于 某一天的17:30
某一天用参数@starttime
下面3个答案我都尝试过,不太行.
我想界定一个 starttime>某一天 某一个时间
比如说starttime>2010/08/11 17:30:00 可以表示
如果把日期换成参数该怎么表示
starttime>@starttime 17:30:00
类似的?如何做
是在sql server 2005环境中
说具体一些吧
select a.DNIS,count(*) as total from dbo.Call a where a.dnis=@dnis
and a.BeginTime between @starttime and @endtime
group by a.DNIS
这段文字 我想加个条件 就是begintime 大于 某一天的17:30
某一天用参数@starttime
下面3个答案我都尝试过,不太行.
▼优质解答
答案和解析
select a.DNIS,count(*) as total from dbo.Call a where a.dnis=@dnis
and a.BeginTime between @starttime and @endtime
and
(
a.BeginTime between
cast(
cast(year(a.BeginTime) as varchar(4))+'-'+
cast(month(a.BeginTime) as varchar(2))+'-'+
cast(day(a.BeginTime) as varchar(2))+' 17:30:00'
as datetime)
and
cast(
cast(year(a.BeginTime) as varchar(4))+'-'+
cast(month(a.BeginTime) as varchar(2))+'-'+
cast(day(a.BeginTime) as varchar(2))+' 22:30:00'
as datetime)
)
group by a.DNIS
-----------------------------------------
select a.DNIS,count(*) as total from dbo.Call a where a.dnis=@dnis
and a.BeginTime between @starttime and @endtime
and a.BeginTime > cast(
cast(year(@starttime) as varchar(4))
+'-'+cast(month(@starttime) as varchar(4))
+'-'+cast(day(@starttime) as varchar(4))
+' 17:30:00'
as datetime)
group by a.DNIS
-------------------------------------------------
select * from t1 where starttime > cast(
cast(year(@starttime) as varchar(4))
+'-'+cast(month(@starttime) as varchar(4))
+'-'+cast(day(@starttime) as varchar(4))
+' 17:30:00'
as datetime)
and a.BeginTime between @starttime and @endtime
and
(
a.BeginTime between
cast(
cast(year(a.BeginTime) as varchar(4))+'-'+
cast(month(a.BeginTime) as varchar(2))+'-'+
cast(day(a.BeginTime) as varchar(2))+' 17:30:00'
as datetime)
and
cast(
cast(year(a.BeginTime) as varchar(4))+'-'+
cast(month(a.BeginTime) as varchar(2))+'-'+
cast(day(a.BeginTime) as varchar(2))+' 22:30:00'
as datetime)
)
group by a.DNIS
-----------------------------------------
select a.DNIS,count(*) as total from dbo.Call a where a.dnis=@dnis
and a.BeginTime between @starttime and @endtime
and a.BeginTime > cast(
cast(year(@starttime) as varchar(4))
+'-'+cast(month(@starttime) as varchar(4))
+'-'+cast(day(@starttime) as varchar(4))
+' 17:30:00'
as datetime)
group by a.DNIS
-------------------------------------------------
select * from t1 where starttime > cast(
cast(year(@starttime) as varchar(4))
+'-'+cast(month(@starttime) as varchar(4))
+'-'+cast(day(@starttime) as varchar(4))
+' 17:30:00'
as datetime)
看了 SQL日期参数加具体钟点时间...的网友还看了以下:
平面向量.的问题已知P={a|a=(1,0)+m(0,1),m∈R},Q={b|b=(1,1)+n 2020-06-06 …
设函数f(x)=a2+asinx+2a2+acosx+2(x∈R)的最大值为M(a),最小值为m( 2020-07-09 …
设一组初始记录关键字序列为(Q,H,C,Y,P,A,M,S,R,D,F,X),则按字母升序的第一趟 2020-07-17 …
一个代数问题R是一个带单位元的交换环,{Mi}是一族R模,{Ni}也是一族R模,M,N是两个R模如 2020-07-21 …
高一一道数学题,关于集合.已知集合M={x∈R\5ax^2-3x+2=0,a∈R}若M中的元素至多 2020-07-30 …
对a的某去心邻域N°(a,r)内任何收敛于a的数列{xn}有f(xn)→m(n→∞)证明:f(x) 2020-07-31 …
{(矩形)}交{(正方形)}={(锐角)}交{(钝角)}=若集合A={X|-1≤X≤5,X∈R}, 2020-08-02 …
设函数f(x)=lgm-1i=1ix+mxam,其中a∈R,m是给定的正整数,且m≥2,如果不等式f 2020-11-01 …
英语翻译E.A.R.L.M.B.LAVILLEPROPRIETAIREAF33760SOULIGAC 2020-11-07 …
十万火急!高一有关指数的数学题.已知a,b,c,m都是正数,且a^m=b^m+c^m,求当m取何值时 2021-02-05 …