SQL Financial Year Query I'd like to be able to have this query running daily selecting only where central_enquiry.enquiry_time is in the current financial year. The financial year runs from 01/04/YYYY to 31/03/YYYY. Ideally this would be dynamic so that I wouldn't have to manually change the dates next April

SELECT
  central_enquiry.enquiry_number,
  central_enquiry.enquiry_name,
  central_enquiry.enquiry_time
FROM
  central_enquiry
WHERE
  central_enquiry.enquiry_time
with start_date (d) as ( select
  case when current_timestamp &lt; CONVERT(datetime,
          cast(datepart(yyyy, current_timestamp) as varchar) +
          '-04-01T00:00:00.000', 126)
    then convert(datetime,
           cast(datepart(yyyy, current_timestamp) - 1 as varchar)
           + '-04-01T00:00:00.000', 126)
    else convert(datetime,
           cast(datepart(yyyy, current_timestamp) as varchar) +
          '-04-01T00:00:00.000', 126)
  end )
SELECT central_enquiry.enquiry_number,
       central_enquiry.enquiry_name,
       central_enquiry.enquiry_time
    FROM central_enquiry, start_date sd
    WHERE central_enquiry.enquiry_time &gt;= sd.d
      AND central_enquiry.enquiry_time &lt;  dateadd(yyyy,1,sd.d)


This should always select data for the current book year.