Quantcast
Viewing all articles
Browse latest Browse all 4871

T-SQL solution to find out how many weeks have passed between 2 dates

I need a T-SQL solution to find out how many weeks have passed between 2 dates.
The week starts on a Monday and ends on a Friday.
So if the date was this Thursday and the new date is next Monday I need the answer to be 1.
In other words I do not need to be counting full weeks. This is necessary to change dates in multiple weeks of a project when a target date changes.


So if the target date is Thursday 2018/12/06 and it's changed to Tuesday 2018/12/18 my answer would be 2. (remember I do not count full weeks). Each instance passed a Monday is considered a week. And I need it to start changing (adding the weeks) with the current weeks Monday. So if today was Tuesday 11/27/2018 these would be my old dates and new dates. (There are dates before the target date and after the target date).

Original dates. New dates
...


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>