热门文章
 
SQL SERVER 和AC
判断access数据库中某个
Access数据库的存储上限
Access2000数据库8
论ACCESS的性能
ASP+ACCESS 无限级
asp中使用access的系
以编程方式创建“自动编号”字
通用删除某表某字段满足条件的
使用中型Access数据库的
 推荐文章
 
asp中使用access的系
深入了解 Microsoft
ACCESS中使用SQL语句
一句代码得到表中的某行的指定
保护Access数据库的安全
使用中型Access数据库的
通用删除某表某字段满足条件的
以编程方式创建“自动编号”字
Access 数据库表规格
ASP+ACCESS 无限级
判断access数据库中某个
Access2000数据库8
Access数据库的存储上限
SQL SERVER 和AC
access能隐藏表而不出现
ACCESS技巧集
 
你现在的位置:您现在的位置是: 中国ASP>>数据库>>access
如何使用 Access 2000


Overview
This article explains how to use Access 2000 date functions when determining 1) the number of work days representing an interval between two dates, and 2) the projected end working date calculated from a start date and number of hours worked.

The user enters in a start date and actual hours as parameters in the GetEndWorkDay function. The function calculates the date in the future the work should be completed. So, if today is 12/2/2002 and the actual hours is 12, the projected end date would be 12/3/2002.

The second part uses the GetNumberOfWorkDays function to determine what percent of the estimated time actual time represents. Estimated work days is the time interval to complete a task based on a start and end date. Comparing estimated to actual time, we can provide the percent of work completed both under or over allocated percents.




GetEndWorkDay Function

Public Function GetEndWorkDay(sStartDate, sHours)
Dim iHoursToDays
Dim iCount
Dim bFlag
Dim sEndDate
Dim sCheckDate
Dim iFoundCount
Dim sDay

'Assume an eight hour day
iHoursToDays = round(sHours / 8,0)
sEndDate = sStartDate
If iHoursToDays > 1 Then
bFlag = False
iCount = 0
iFoundCount = 0
Do While bFlag = False
iCount = iCount + 1
sCheckDate = DateAdd("d", iCount, sStartDate)
sDay = Weekday(sCheckDate)
If sDay <> 1 And sDay <> 7 Then
sEndDate = sCheckDate
iFoundCount = iFoundCount + 1
End If
If iFoundCount >= iHoursToDays Then
Exit Do
End If
Loop
End If
GetEndWorkDay = sEndDate
End Function

DateAdd returns a date to which a specific time interval has been added. In this sample the interval is "Day".
List of Interval Settings:
yyyy = year
q = quarter
m = month
y = day of year
d = day
w = weekday
ww = week
h = hour
n = minute
s = second


Increment through a range of possible work days to find the end work date. The number of work days is determined by dividing the hours by eight. This assumes an eight hour work day. Ignore saturday and sunday as work days. Once the number of found work days equals the work day interval, stop and return the date as the final work date.



GetNumberofWorkDays Function
Public Function GetNumberOfWorkDays(sStartDate, sEndDate)
Dim iDays
Dim iWorkDays
Dim sDay
Dim i

iDays = DateDiff("d", sStartDate, sEndDate)

iWorkDays = 0

For i = 0 To iDays
'First day of the week is sunday
sDay = Weekday(DateAdd("d", i, sStartDate))
If sDay <> 1 And sDay <> 7 Then
iWorkDays = iWorkDays + 1
End If
Next
GetNumberOfWorkDays = iWorkDays
End Function

DateDiff specifics a number of time intervals between two dates.
DateDiff (interal,date1,date2,firstdayofweek,firstweekofyear)

Interval
yyyy = year
q = quarter
m = month
y = day of year
d = day
w = weekday
ww = week
h = hour
n = minute
s = second
date1 and date2 are used to calculate the interval
firstdayofweek is sunday unless specified
firstweekofyear is jan 1 unless specified


Weekday returns a number representing the day of the week.

Return values are:
Sunday = 1
Monday = 2
Tuesday = 3
Wednesday = 4
Thursday = 5
Friday = 6
Saturday = 7

First determine the number of days between the two dates. Calculating the number of work days is done by not adding Saturday and Sunday dates. A query extract from a table containing all the holidays for the year could also be added for increased accuracy.

相关信息:

在 Access 中使用“存储过程”
SQL SERVER 和ACCESS/excel的数据导入导出
判断access数据库中某个表是否存在
Access数据库的存储上限
Access2000数据库80万记录通用快速分页类
论ACCESS的性能
ASP+ACCESS 无限级目录树
asp中使用access的系统表的方法

 

中国ASP技术 ASP.ORG.CN 版权所有 2004-2008