Reputation: 429
I have a variable that saves the start date of the current financial year which starts from 1st April as CurrentFY = #1/4/2020#
in a #d/m/yyyy#
format
This means that when 1st April 2021 arrives, i have to manually update this variable to CurrentFY = #1/4/2021#
. Is there a way to automatically update this variable yearly?
Upvotes: 1
Views: 110
Reputation: 55981
There is no need to "update" anything, as you can create your CurrentFY
dynamically:
CurrentFY = DateSerial(Year(DateAdd("m", -3, Date)), 4, 1)
Upvotes: 1
Reputation: 37119
You can create a string dynamically and then convert it to date like so:
CurrentFY = CDate("1/4/" & Year(Date))
That way, any time the code runs, Year(Date) gives you year of current date.
Upvotes: 0