I am trying to write a query that will give me the max date form Table_A based on the following condition.
If the given date (input parameter) falls between 01 April and 30 Sept of that year then return MAX(date) prior to April 1.
OR
If the given date (input parameter) falls between 01 Oct and 31 March of the following year then return MAX(date) prior to Oct 1.
For example :
- Given date is 27th Dec, 2012 (date between 01 Oct and 31 March of the following year)
return 29th Sept, 2012 - Given Date is 17th Aug, 2012 (date between 01 April and 30 Sept of the following year)
return date (MAX DATE prior to is 01 April is 29th March)
try this:
so you input date is in the
dtepartand
eg a small test: