简体   繁体   English

如何检查日期时间列之间的日期时间

[英]How to check the Datetime between the Datetime columns

How to check the Datetime between the Datetime columns?如何检查日期时间列之间的日期时间?

For example:例如:

Column1             Column2         Price
------------------------------------------
01/05/2019          31/06/2019        50
01/07/2019          31/09/2019        49
01/10/2019          31/12/2019        48
01/01/2020          31/01/2020        45

Now, how can I send Price based on dates?现在,如何根据日期发送价格?

If today date is 01/06/2019 then we will send the price as 50 or today's date is 25/01/2020 then we will send 45 like that.如果今天的日期是 01/06/2019,那么我们将发送价格为 50,或者今天的日期是 25/01/2020,那么我们将发送 45。

How can I do this query?我该怎么做这个查询?

Just use只需使用

SELECT Price FROM [TableName] WHERE GETDATE() BETWEEN Column1 AND Column2

As long as the Date columns do not overlap and reflect 1 price for each given period.只要日期列不重叠并反映每个给定期间的 1 个价格。

SQL Compliance SQL 合规性

In Oracle use CURRENT_DATE instead of GETDATE()在 Oracle 中使用 CURRENT_DATE 而不是 GETDATE()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM