两个日期之间的SQL日期 [英] SQL Date between Two Date
本文介绍了两个日期之间的SQL日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的,
假设我的InvoiceTable由InvoiceNo,InvoiceStartDate,InvoiceEndDate列组成,那么如何将SQL放在InvoiceStartDate和InvoiceEndDate之间的条件下面是查询只有一列。
选择 InvoiceNo 来自 InvoiceTable 其中
InvoiceEndDate 日期 ' 2011/02/25' 和 ' 2011/02/27'
请帮忙解决这个问题>
谢谢
Basit。
解决方案
我不太清楚你的意思通过如何把SQL放在conditi之间on InvoiceStartDate和InvoiceEndDate 但我想其中一个就是你想要的:
选择 InvoiceNo 来自 InvoiceTable
其中 InvoiceEndDate ' 2011/02/25' 和 ' 2011/02/27'
和 InvoiceStartDate ' .... / .. / ..' 和 ' .... / .. / ..';
选择 InvoiceNo 来自 InvoiceTable
其中 ' .... / .. / ..' InvoiceStartDate 和 InvoiceEndDate;
< blockquote>使用 AND
。
示例
选择 InvoiceNo 来自 InvoiceTable 其中
(InvoiceEndDate 日期 ' 2011/02/25' 和 ' 2011/02/27')和
(InvoiceStartDate 日期 < span class =code-keyword> ' 2 011/02/25' 和 ' 2011/02/27' 跨度>)
Dear,
Suppose if i have InvoiceTable consist of InvoiceNo, InvoiceStartDate, InvoiceEndDate Column then how to put the SQL between condition on InvoiceStartDate and InvoiceEndDate Below is the query of only one column.
select InvoiceNo from InvoiceTable where
InvoiceEndDate Date between '2011/02/25' and '2011/02/27'
Please help on this
Thanks
Basit.
解决方案
I'm not quite sure what you mean by "how to put the SQL between condition on InvoiceStartDate and InvoiceEndDate" but I guess one of these will be what you want:
select InvoiceNo from InvoiceTable where InvoiceEndDate between '2011/02/25' and '2011/02/27' and InvoiceStartDate between '..../../..' and '..../../..';
select InvoiceNo from InvoiceTable where '..../../..' between InvoiceStartDate and InvoiceEndDate;
Use anAND
.
Example
select InvoiceNo from InvoiceTable where (InvoiceEndDate Date between '2011/02/25' and '2011/02/27') and (InvoiceStartDate Date between '2011/02/25' and '2011/02/27')
这篇关于两个日期之间的SQL日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文