Home > front end >  How to find the next 31st March
How to find the next 31st March

Time:04-06

At the point of running some code I want to be able to return the next 31st of March.

So if run today tye date returned would be 31st March 2023. But if the same code was run back on say the 1st of March 2022 then the 31st of March would be returned....not sure of the best way to achieve this.

CodePudding user response:

A little date arithmetic should work here:

DATEFROMPARTS(YEAR(DATEADD(MONTH,-3,GETDATE()) 1,3,31)

CodePudding user response:

Hi thanks for getting me on the right track. I went with this very similar code -

DATEFROMPARTS (YEAR(DATEADD(MONTH,-3,GETDATE()) 1), 3, 31 )

  • Related