You might want to verify your requirements first before attempting something like this. For example how many "days" exist between the following periods? How many "hours"?How many "days"? And does the answer change if the time zone does? - July 7, 23:40 to July 8, 00:15 - Dec 31, 23:40 to Jan 1, 00:15 These are often business requirements and depends on what business needs are. As another extreme example if one needs seven "business" days around December 25th then what impacts do holidays and weekends have on what the actual span is.