Reputation: 23
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.
How can I do this query?
Upvotes: 1
Views: 49
Reputation: 624
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.
SQL Compliance
In Oracle use CURRENT_DATE instead of GETDATE()
Upvotes: 2