0

how to dynamic current year to Previous 5 year display year in filter(Drop Down)

how to dynamic Financial Year to Previous 5 Financial year display year in filter(Drop Down)

Please find attachment screensort.enter image description here

user6349948
  • 33
  • 1
  • 6

1 Answers1

1

Assuming you don't have a table with date that you can use you could do something like this

SELECT * FROM (
select YEAR(getdate()) as [TimePeriod]
UNION SELECT YEAR(getdate()) -1
UNION SELECT YEAR(getdate()) -2
UNION SELECT YEAR(getdate()) -3
UNION SELECT YEAR(getdate()) -4
) t
ORDER By TimePeriod DESC
Alan Schofield
  • 19,839
  • 3
  • 22
  • 35