I have two dates, effective date '2023-07-03' to expiry date '2024-03-31'. I want to retrieve record on getdate()
.
But I am not getting the results from my query:
SELECT
[ID],
[Tariff_ID],
[Effective_Date],
[Expiry_Date],
[Category],
[Cargo_Class],
[Wt_Min], [Wt_Max],
[Charges_PKR], [Charges_Per]
FROM
[CARGO].[dbo].[Tariff_Handling]
WHERE
Effective_Date >= GETDATE()
AND Wt_Min <= 4
AND Category = 'AFU'
AND Cargo_Class = 'GEN'
AND Tariff_ID = 1
My current date is greater than to effective date and less than to expiry date but I'm getting any results
2条答案
按热度按时间nwlls2ji1#
The issue with your query lies in the condition
Effective_Date >= GETDATE()
. This condition is preventing any records from being retrieved because the effective date of the record '2023-07-03' is not greater than or equal to the current date.5cg8jx4n2#
There
where
clause needs to be:It'll then match an expiry date of
2024-03-31
when current time is2024-03-31 23:59:59.999