我想写这种查询正确的方法吗?使用2个参数之间的搜索关系 [英] I want write this queary correct way?search buttion between using 2 parameters

查看:65
本文介绍了我想写这种查询正确的方法吗?使用2个参数之间的搜索关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SELECT * FROM tblPickupDetails在哪里(" + FromDate +"" +"00:00:00.000"和" + Todate +''+''23:59:59.999"之间的接收时间) )

此查询有什么错误?

我尝试在使用2个参数之间编写搜索关系.

SELECT * FROM tblPickupDetails WHERE (Recivedtime BETWEEN ''" + FromDate + "'' + ''00:00:00.000'' AND ''" + Todate + "''+''23:59:59.999'')

what''s the error this queary??

i try to write search buttion between using 2 parameters

推荐答案

If u getting two parameter @fromdate and @todate then why u adding a time. Your are going to compare the time?

Eg.
SELECT * FROM tblPickupDetails WHERE (Recivedtime BETWEEN @fromdate AND @Todate )

Above query will work perfectly try this.


您好Haisya,

在开始日期和结束日期的时间字符串之前放置一个空格.和报价是不正确的.像这样尝试..

Hi Haisya,

put one space before the time string in both start and end date. And quotations are incorrect. Try like this ..

DECLARE @FromDate VARCHAR(15)= '01/01/2012'
DECLARE @Todate VARCHAR(15)='12/31/2012'

SELECT 1 WHERE (GETDATE() BETWEEN ''+@FromDate+''+' 00:00:00.000' AND ''+@Todate+''+' 23:59:59.999')

Like this you can modify your query..

SELECT * FROM tblPickupDetails WHERE (Recivedtime BETWEEN '' + @FromDate + '' + ' 00:00:00.000' AND '' + @Todate + ''+' 23:59:59.999')



谢谢



Thank you


这篇关于我想写这种查询正确的方法吗?使用2个参数之间的搜索关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆