dprichard Posted April 23, 2007 Share Posted April 23, 2007 I have been searching trying to figure out if this is possible. I need to figure out how many days are between certain dates excluding weekends. Is it possible to do this. I have tried searching google, but I guess I am not using the right keywords because the results I am getting back aren't giving me much help. I was thinking about setting up a table and putting in all weekend dates and then pulling in that data, but thought there might be an easier way. ??? ??? ??? Link to comment https://forums.phpfreaks.com/topic/48280-using-only-weekdays-and-excluding-weekends-when-calculating-dates/ Share on other sites More sharing options...
fenway Posted April 23, 2007 Share Posted April 23, 2007 Interesting question -- I guess there are many ways to do this. Easiest way IMHO is to find out how many full weeks are between your dates (which means 2 weekend days), and then simply determine where the extra days are. For example, if it's from this Wendesday to 3 Fridays from now, you have 3 full weeks (wed-wed), and no weekends between wed & fri. make sense? Link to comment https://forums.phpfreaks.com/topic/48280-using-only-weekdays-and-excluding-weekends-when-calculating-dates/#findComment-236022 Share on other sites More sharing options...
bubblegum.anarchy Posted April 24, 2007 Share Posted April 24, 2007 As fenway suggested, the difference in the amount of weekends during a period will determine how many days without occur during a period... the following is a starting point that will work for a period starting and ending on a weeday that is greater than one week - Try to develop this to cater for weekend starting and ending points as well as periods shorter than one week. SET @date_start := '2007-04-03'; SET @date_end := '2007-04-17'; SELECT datediff(@date_end, @date_start) - round(datediff(@date_end, @date_start) / 7) * 2; Link to comment https://forums.phpfreaks.com/topic/48280-using-only-weekdays-and-excluding-weekends-when-calculating-dates/#findComment-236574 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.