朋友请帮助编写sql查询

朋友请帮助编写sql查询

本文介绍了朋友请帮助编写sql查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,
我想从其RecieveTime在给定日期之间的DateBase访问电子邮件. 我只想匹配或比较日期部分..
我写了这个查询,但是及时出现了一些问题
我不想比较时间.
我正在使用Sql Server 2005和.net 2.0框架工作

Hi Friends ,
I Want to access Email from my DateBase whose RecieveTime Is Between given dates ..
I only want to match or compare the date part ..
I write this query but there is some problem in time
I dont want to compare time.
I am Using Sql Server 2005 and .net 2.0 Frame work

select * from OUTLOOK_DETAIL where  convert(datetime,'" + Program.datefrom + "')<=RECEIVE_TIME  and  convert(datetime,'" + Program.dateto + "')>=RECEIVE_TIME order by RECEIVE_TIME

推荐答案


select *
from OUTLOOK_DETAIL
where RECEIVE_TIME BETWEEN @datefrom AND @dateto
order by RECEIVE_TIME


select * from
OUTLOOK_DETAIL
where  '" + Program.datefrom + "' <=  convert(varchar(10),RECEIVE_TIME,101) and  '" + Program.dateto + "' >= convert(varchar(10),RECEIVE_TIME,101) order by
RECEIVE_TIME



检查以下链接以了解其他选项:

http://weblogs.sqlteam.com/jeffs/archive/2004/12/02/2954.aspx [ ^ ]



check the following link for other options:

http://weblogs.sqlteam.com/jeffs/archive/2004/12/02/2954.aspx[^]


这篇关于朋友请帮助编写sql查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 12:20