我尝试过查询但显示错误
我有一张桌子如下
select * from plandate
Fromdate Todate >
2017-03-02 2017-03-08
i希望在日期和日期之间显示使用上面两个表的日期。
如何编写sql server查询。
i希望输出为
03/06/2017
04/06/2017
/ 05/06
06/06/2017
我尝试了以下查询,如下所示
SELECT * FROM Plandate
WHERE CONVERT( VARCHAR,date,111)> = CONVERT(VARCHAR,@ Fromdate,111)
和CONVERT(VARCHAR,date,111)< = CONVERT(VARCHAR,@ Todate,111)
当我执行上述查询时我得到如下错误
必须声明标量变量@fromdate
我尝试了什么:
i有一张桌子如下
select * from plandate
Fromdate Todate
2017-03-02 2017-03-08
i希望使用上面两张表显示日期和日期之间的日期。
表示如何编写sql server查询。
i想要输出为
/>
03/06/2017
05/06/2017
06 / 06/2017
07/06/2017
获得以上输出我尝试了以下查询如下
SELECT * FROM Plandate
WHERE CONVERT(VARCHAR,date,111)> = CONVERT(VARCHAR,@ Fromdate,111 )
和CONVERT(VARCHAR,date,111)< = CONVERT(VARCHAR,@ Todate,111)
当我执行以上查询我得到如下错误
必须声明标量变量@fromdate
i have one table as follows
select * from plandate
Fromdate Todate
2017-03-02 2017-03-08
i want to display in between those date from date and to date using above two table.
for that how to write the sql server query.
i want the output as
03/06/2017
04/06/2017
05/06/2017
06/06/2017
07/06/2017
for getting a above output i tried my below query as follows
SELECT * FROM Plandate
WHERE CONVERT(VARCHAR,date, 111) >=CONVERT(VARCHAR,@Fromdate,111)
And CONVERT(VARCHAR,date, 111) <=CONVERT(VARCHAR,@Todate,111)
when i execute the above query i get error as follows
Must declare the scalar variable "@fromdate"
What I have tried:
i have one table as follows
select * from plandate
Fromdate Todate
2017-03-02 2017-03-08
i want to display in between those date from date and to date using above two table.
for that how to write the sql server query.
i want the output as
03/06/2017
04/06/2017
05/06/2017
06/06/2017
07/06/2017
for getting a above output i tried my below query as follows
SELECT * FROM Plandate
WHERE CONVERT(VARCHAR,date, 111) >=CONVERT(VARCHAR,@Fromdate,111)
And CONVERT(VARCHAR,date, 111) <=CONVERT(VARCHAR,@Todate,111)
when i execute the above query i get error as follows
Must declare the scalar variable "@fromdate"
检查@Fromdate
和@Totate
:
它们是什么?
它们来自哪里?
如果它们是paprmeters,你必须声明它们。
看起来像date
,@Fromdate
和@Totate
在开头是datetime数据类型,为什么在比较前转换它们?
提供此查询的人应该知道错误的原因。
Check@Fromdate
and@Todate
:
what are they ?
Where are they coming from ?
If they are paprmeters, you must declare them.
Looks likedate
,@Fromdate
and@Todate
are datetime datatype in the beginning, why do you convert them before comparing ?
The person who gave you this query should know the why of the error.