To get the last day of a semester, I am using the below query:
select dateadd(quarter, datediff(quarter, 0, @mydate) / 2 * 2 + 2, -1)
I want to use a similar approach to get the first day of half year based on a given date.
For example, if my date is 5th of March 2024, then the SQL should return 1st of January 2024.
And if my date is 15th of November 2024. then the SQL should return 1st July 2024.
Any help please?
Semester,QuarterorHalfYearfield