Substraction

B

bladelock

Good day,

I want to create a query that will consist of three fields: AdmDate,
DischDate, and NoDays.

AdmDate will have dates of admission
DischDate will have dates of Discharges
NoDays will be a subtraction of AdmDate-DischDate.

How can I make the query calculate all data that are both fields to populate
in the NoDays fields. Example

AdmDate DischDate NoDays
01/01/2009 01/01/2009 1
02/05/2009 02/10/2009 5
05/20/2009 05/29/2009 9
So on. I can manually do but there are too many records!!

Thanks
 
J

John W. Vinson

Good day,

I want to create a query that will consist of three fields: AdmDate,
DischDate, and NoDays.

AdmDate will have dates of admission
DischDate will have dates of Discharges
NoDays will be a subtraction of AdmDate-DischDate.

How can I make the query calculate all data that are both fields to populate
in the NoDays fields. Example

AdmDate DischDate NoDays
01/01/2009 01/01/2009 1
02/05/2009 02/10/2009 5
05/20/2009 05/29/2009 9
So on. I can manually do but there are too many records!!

Thanks

The SQL of the query would be

SELECT [AdmDate], [DischDate], DateDiff("d", [AdmDate], [DischDate])
FROM yourtablename;

This will get 0 for a patient admitted and discahrged on the same day, but
will get the correct number of days in the other examples... you could use

IIF([AdmDate] = [DischData], 1, DateDiff("d", [AdmDate], [DischDate]))

to handle this special case.
 
K

KARL DEWEY

I think you will need to add one as the results will be 0 (zero) if admit and
discharge on same date.

NoDays: DateDiff("d", [AdmDate], [DischDate])+1

--
Build a little, test a little.


Daniel Pineault said:
In your query for the NoDays Field try something like

NoDays: DateDiff("d", [AdmDate], [DischDate])

--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.



bladelock said:
Good day,

I want to create a query that will consist of three fields: AdmDate,
DischDate, and NoDays.

AdmDate will have dates of admission
DischDate will have dates of Discharges
NoDays will be a subtraction of AdmDate-DischDate.

How can I make the query calculate all data that are both fields to populate
in the NoDays fields. Example

AdmDate DischDate NoDays
01/01/2009 01/01/2009 1
02/05/2009 02/10/2009 5
05/20/2009 05/29/2009 9
So on. I can manually do but there are too many records!!

Thanks
 
J

jamie liddle

bladelock said:
Good day,

I want to create a query that will consist of three fields: AdmDate,
DischDate, and NoDays.

AdmDate will have dates of admission
DischDate will have dates of Discharges
NoDays will be a subtraction of AdmDate-DischDate.

How can I make the query calculate all data that are both fields to
populate
in the NoDays fields. Example

AdmDate DischDate NoDays
01/01/2009 01/01/2009 1
02/05/2009 02/10/2009 5
05/20/2009 05/29/2009 9
So on. I can manually do but there are too many records!!

Thanks
 
L

Larry Linson

Maybe, Steve, you ought to ask the poster what he/she wants, before
criticizing a posted solution.

There are a number of ways to describe this. A vacation package might well
count each day... as in a 3 day, 2 night vacation. A hospital might well
charge in the same way... so a Monday admit and Monday discharge would be 1,
a Monday admit and Tuesday discharge would be 2. That could be described as
any part of a day on date of admit or discharge counts as a full day.

It's also possible that time might enter into the determination... any stay
up to 24 hours is 1, any from 24 to 48 is 2, ...

But, it's within the realm of reason that they may want to count some other
way, too.

Larry


Steve said:
By adding 1, if they are not the same day, the result will be one too many
days.

Steve
(e-mail address removed)


KARL DEWEY said:
I think you will need to add one as the results will be 0 (zero) if admit
and
discharge on same date.

NoDays: DateDiff("d", [AdmDate], [DischDate])+1

--
Build a little, test a little.


Daniel Pineault said:
In your query for the NoDays Field try something like

NoDays: DateDiff("d", [AdmDate], [DischDate])

--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.



:

Good day,

I want to create a query that will consist of three fields: AdmDate,
DischDate, and NoDays.

AdmDate will have dates of admission
DischDate will have dates of Discharges
NoDays will be a subtraction of AdmDate-DischDate.

How can I make the query calculate all data that are both fields to
populate
in the NoDays fields. Example

AdmDate DischDate NoDays
01/01/2009 01/01/2009 1
02/05/2009 02/10/2009 5
05/20/2009 05/29/2009 9
So on. I can manually do but there are too many records!!

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

Top