问题描述
emp_name emp_state joining_date
1 Surendra Kumar Verma Uttar pradesh 01/01/2012
2 Prem Kumar Verma Uttar pradesh 02/02/2012
3 Rajendra Kumar Verma Uttar pradesh 05/04/2012
4 Suresh Kumar Verma Uttar pradesh 02/08/2012
5 Aditya Rajput Delhi 06/12/2012
我想使用诸如Query
的between子句
i want to use between clause like this Query
select emp_name,emp_state from emp_reg where joining_date between ''01/01/2012'' and ''06/02/2012''
但这不能提供正确的输出
谁能告诉我在带日期的子句之间使用正确的格式是什么.
我正在使用Sql Server2005.
but this is not giving correct output
can anybody tell me what is the correct format to use between clause with dates.
i''m using Sql server 2005.
推荐答案
SELECT *
FROM emp_reg
WHERE joining_date between Convert(datetime ,'01/01/2012') AND Convert(datetime ,'06/02/2012');
让我知道它是否对您不起作用.
Let me know if it won''t work for you.
select emp_name,emp_state from Code where joining_date between '01/01/2012' and '06/02/2012'
就像您在上面写的一样,并输入了您插入的相同值..
我的桌子设计是:
列名数据类型允许为空
emp_name | nchar(30)|
emp_state | nchar(50)|
加入日期|日期|
我让所有值都不为空.
因此,我在您的数据表中插入了前3个数据作为答案,作为正确的输出.
总体而言,我建议您使用 作为数据类型
as you wrote above and Entered the same values you inserted..
my table design is:
Column Name Data Type Allow Null
emp_name | nchar(30) |
emp_state | nchar(50)|
joining_date| date|
I kept all values not null.
Therefore I got Top 3 data insterted in your data table as answer as a correct output.
Overall,I suggest you to Use as Datatype
这篇关于SQL Server 2005之间带有日期的子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!