T-SQL Dynamic Date based on Today’s Month

My fiscal year begins on April 1 and I need to include 1 full year of historical data plus current fiscal year as of today. In DAX this looks like:

DATESBETWEEN ( Calendar_Date, IF ( MONTH ( TODAY() < 4, DATE ( YEAR ( TODAY())-2, 4, 1),DATE ( YEAR ( TODAY())-1, 4, 1)), DATE ( TODAY()))

I need to create this same range as a filter in a T-SQL query, preferably in the "WHERE" clause, but I am totally new to sql and have been unsuccessful in finding a solution online. Any help from more experienced people would be much appreciated!



Read more here: https://stackoverflow.com/questions/68478281/t-sql-dynamic-date-based-on-todays-month

Content Attribution

This content was originally published by Patrick at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: