Monthly data based on dates

C

CF

Hello,

I am new to Access and trying to get an employee database. Now, I like to
have a query/report (that I can afterwards download to excel) that tells me
if a person was in the company during a certain month or not - based on the
start date and end date. The end date can be empty.

What I am doing now is to have a query for each month that tells me if the
person was in the company or not, with the following calculation:
Jan 09: IIf([Employee]![Start Date]<=31/1/2009 And ([Employee]![End
Date]>=31/1/2009 Or [Employee]![End Date]=""),1,0)

However this doesn't give the desired result. Any suggestion?

Thanks.
 
K

Ken Snell [MVP]

Try this -- Use Nz function to replace a NULL date in your table with
today's date (or you can use any other date you wish), and change your date
format to the US version (which is how ACCESS will interpret dates in a
x/x/yyyy format), and delimit the dates with # characters:

Jan 09: IIf([Employee]![Start Date]<=#1/31/2009# And Nz([Employee]![End
Date], Date())>=#1/31/2009#,1,0)
 
C

CF

Great - this works fine.

Thanks a lot.

Ken Snell said:
Try this -- Use Nz function to replace a NULL date in your table with
today's date (or you can use any other date you wish), and change your date
format to the US version (which is how ACCESS will interpret dates in a
x/x/yyyy format), and delimit the dates with # characters:

Jan 09: IIf([Employee]![Start Date]<=#1/31/2009# And Nz([Employee]![End
Date], Date())>=#1/31/2009#,1,0)

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/



CF said:
Hello,

I am new to Access and trying to get an employee database. Now, I like to
have a query/report (that I can afterwards download to excel) that tells
me
if a person was in the company during a certain month or not - based on
the
start date and end date. The end date can be empty.

What I am doing now is to have a query for each month that tells me if the
person was in the company or not, with the following calculation:
Jan 09: IIf([Employee]![Start Date]<=31/1/2009 And ([Employee]![End
Date]>=31/1/2009 Or [Employee]![End Date]=""),1,0)

However this doesn't give the desired result. Any suggestion?

Thanks.
 

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

Similar Threads


Top