TechArena Community find period in days / hours excluding weekdays between two days?

#1
19-06-2009
 Member Join Date: May 2008 Posts: 97
find period in days / hours excluding weekdays between two days?

Hi,

Is there any way of calculating the total period between the two dates in days or hrs excluding the weekdays?
#2
19-06-2009
 Member Join Date: Jan 2008 Posts: 1,515
Re: find period in days / hours excluding weekdays between two days?

USE DateDiff Function

DateDiff(DateInterval.Day, dtmStart, dtmEnd)

Code:
```Public Overloads Function DateDiff( _
ByVal Interval As String, _
ByVal Date1 As Object, _
ByVal Date2 As Object, _
Optional ByVal DayOfWeek As FirstDayOfWeek = FirstDayOfWeek.Sunday, _
Optional ByVal WeekOfYear As FirstWeekOfYear = FirstWeekOfYear.Jan1 _
) As Long```

You need to assign values to dtmStart(start date) & dtmEnd(end date).

http://msdn.microsoft.com/en-us/libr...6f(vs.71).aspx
#3
19-06-2009
 Member Join Date: Nov 2008 Posts: 85
Re: find period in days / hours excluding weekdays between two days?

I have the same question for python language?

#4
19-06-2009
 Member Join Date: Nov 2008 Posts: 69
Re: find period in days / hours excluding weekdays between two days?

Python(Script)
This will return the number of days between two dates. In the script I'm using ZopeTime but I can be changed if necessary. Most of the clues to this puzzle were gathered from the Zope List.
Source
from DateTime import DateTime
date1 = DateTime('2001/10/06 14:00:00')
date2 = context.ZopeTime()
return str(date1 - date2)[:2]
Add a script(Python) called time_lapse and paste the source from above.
The returned number of days can then be referenced with the <dtml-var time_lapse>
for details: http://www.zopelabs.com/cookbook/997725258

 Tags: