Dates!

Gillian

New member
Local time
Today, 23:38
Joined
Mar 12, 2002
Messages
6
ok two problems.
1) How can i make a field contain the current date? For example when the user creates a new record, the date the record was created is inserted into the correct field on a form.

And secondly
2) One one of my forms the amount of days a book is overdue has to be calculated. What code can i use to instruct the database not to count saturdays and sunsdays?

Thank you very much for your help!
 
1) insert =Date() in the default value for the field or =Now() to include the time

2)use
NETWORKDAYS
Returns the number of whole working days between a start and end date, excluding weekends and any identified holidays.

If this function returns the #NAME? error value, you may need to install msowcf.dll.

Syntax

NETWORKDAYS(start_date,end_date,holidays)

Start_date is a date that represents the start date.

End_date is a date that represents the end date.

Holidays is an optional range of one or more days (holidays) to exclude from the working calendar.


[This message has been edited by Geoff Codd (edited 03-21-2002).]

[This message has been edited by Geoff Codd (edited 03-21-2002).]
 
With the first solution =date() will this date change each time the form is opened (not edited? or will the date remain the same?
 
For part 2 you could use a more long winded approach

Function dteN(x As Date, y As Date)

Dim z As Date, a As Integer

a = 0

For z = x To y
If Format(z, "dddd") = "Saturday" Or Format(z, "dddd") = "sunday" Then
a = a
Else
a = a + 1
End If
Next z

dteN = a

End Function

It does work ok though

Col
 

Users who are viewing this thread

Back
Top Bottom