Working days calc error

A

Apples76

I am using the Calculate working days function provided by Ken Getz and i
keep on getting data mismatch error when trying to run it.

both of the scource dates are in the medium format (all though i did need to
change on filed from the long format)

does anyone have any ideas?
 
A

Apples76

Hi Allen,

yes you presume correct.

i am trying to use "dhCountWorkdaysA" function and have copied the required
SkipHolidays etc.

I am using Access 2000

the fields are in the same query as the expression and both fields are dates
fileds(medium format) i am not using the Array function for holidays as the
business does not officially recognise them.
 
A

Allen Browne

Okay, dhCountWorkdaysA() accepts 2 days (ignoring the possible list of
holidays.)

If you are getting a type mismatch, Access is not understanding the fields
as dates, or perhaps they are null.

The Format is not relevant. Internally, Access handles date/time values as
numbers (days, and a fraction of a day for the time.) If your field does use
the Format() function, it is a Text field, and that would be the reason for
the type mismatch.

If the field you are passing is a Date/Time field in a table, it will be
fine (unless it's Null.) If it is a calculated query field, you need to
typecast it by wrapping CDate() around the expression. If it is a parameter,
you need to declare it (Parameters on Query menu, in query design.) If it is
a text box, set the control's Format property to General Date.

Here's some information about handling the error:
http://allenbrowne.com/ser-36.html#DataType

If you are still stuck, switch your query to SQL View (View menu in query
design). Copy the SQL statement, and post it here.
 
A

Apples76

Allen,

how do i handle nulls?

Allen Browne said:
Okay, dhCountWorkdaysA() accepts 2 days (ignoring the possible list of
holidays.)

If you are getting a type mismatch, Access is not understanding the fields
as dates, or perhaps they are null.

The Format is not relevant. Internally, Access handles date/time values as
numbers (days, and a fraction of a day for the time.) If your field does use
the Format() function, it is a Text field, and that would be the reason for
the type mismatch.

If the field you are passing is a Date/Time field in a table, it will be
fine (unless it's Null.) If it is a calculated query field, you need to
typecast it by wrapping CDate() around the expression. If it is a parameter,
you need to declare it (Parameters on Query menu, in query design.) If it is
a text box, set the control's Format property to General Date.

Here's some information about handling the error:
http://allenbrowne.com/ser-36.html#DataType

If you are still stuck, switch your query to SQL View (View menu in query
design). Copy the SQL statement, and post it here.
 
A

Allen Browne

If some fields are blank, you will need to either add criteria to your query
so they are excluded before being passed to the function.

If that is not practical, you will need to modify the function so it accepts
Variant instead of Date arguments. Then use IsDate() to test the arguments
before operating on them.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top