gpt4 book ai didi

java - 开始日期和结束日期查询不起作用

转载 作者:行者123 更新时间:2023-11-30 00:59:20 26 4
gpt4 key购买 nike

以下是要求

如果搜索日期范围为 5/15/2013 至 5/21/2013,则将包含或排除具有以下事件日期范围的事件:

1/01/2013 to 6/30/2013 include
2/15/2013 to 3/15/2013 exclude
5/01/2013 to 5/19/2013 include
5/01/2013 to 5/14/2013 exclude
5/15/2013 to 5/15/2013 include
5/21/2013 to 5/21/2013 include
5/17/2013 to 5/30/2013 include
5/16/2013 to 5/20/2013 include
5/22/2013 to 5/30/2013 exclude
*5/16/2013 to 00/00/0000 include
5/22/2013 to 00/00/0000 exclude*

下面是我所做的查询,但它不符合上述条件

SELECT cm_id,cm_date_from,cm_date_to FROM Cat_Master
WHERE TRUE AND ( "2013-05-15" BETWEEN cm_date_from AND cm_date_to OR "2013-05-21" BETWEEN cm_date_from AND cm_date_to
OR "2013-05-15" >= cm_date_from AND "2013-05-21" <= cm_date_to OR "2013-05-15" <= cm_date_from AND "2013-05-21" >= cm_date_to
)

请指导以上查询谢谢

最佳答案

TO_DATE( string1, [ format_mask ], [ nls_language ] )

TO_DATE('2013-05-15,'yyyy-mm-dd')。

对于日期比较,请使用日期变量。

P.S:我假设您正在使用 Oracle Db(因为您没有提及)

关于java - 开始日期和结束日期查询不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20279785/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com