Reputation: 682
I have a query that currently searches for records that have a payment date year within the current year.
I need to modify the query so that it searches records starting from November 15th of the previous year, in this case 2019 to anything within the current year 2020.
How can I add this date range?
This is my current query:
SELECT
RECORD_ID
, RECORD_TYPE
, PERMIT_TYPE
, RECORD_STATUS
, PURCHASE_DATE
, PURCHASE_TIME
, PERMIT_YEAR
, CONTACT_ADDRESS
, CONTACT_NAME
FROM
PERMIT_VIEW PV
INNER JOIN PERMIT BP
ON PV.RECORD_ID = BP.RECORD_ID
INNER JOIN PAYMENT P
ON BP.SERV_PROV_CODE = P.SERV_PROV_CODE
WHERE
RECORD_TYPE IN ('Annual')
AND YEAR(PURCHASED_DATE) = YEAR(GETDATE()) - This is the part I need to change.
AND PV.RECORD_ID NOT LIKE 'DLY%'
AND RECORD_STATUS NOT IN ('Void')
Thank you for your help,
Erasmo
Upvotes: 0
Views: 47
Reputation: 1269733
You can use the condition:
purchased_date >= datefromparts(year(getdate()) - 1, 11, 15)
Upvotes: 1