[AccessD] substract dates

Steve Schapel steve at datamanagementsolutions.biz
Thu Sep 30 04:28:31 CDT 2010


Pedro,

Leaving aside for the moment why these data are in two separate tables, and 
of course I don't know the full story here, but at some stage you might 
consider joining them together.

I think the query you need here will look like this:

SELECT tbl1.patientnr, [Afsluitdatum]-[Uitvoerdatum] As Days, 
Abs(([Afsluitdatum]-[Uitvoerdatum])<365) As TheValue
FROM tbl1 INNER JOIN tbl2 ON tbl1.patientnr = tbl2.patientnr

Regards
Steve

-----Original Message----- 
From: pedro at plex.nl
Sent: Thursday, September 30, 2010 10:39 AM
To: accessd at databaseadvisors.com
Subject: [AccessD] substract dates

Dear List,

i have two tables

tbl1
patientnr        Afsluitdatum
01234567    01-01-2010
09876543    15-01-2010

tbl2
patientnr      Uitvoerdatum
01234567    01-02-2009
09876543    01-01-2009

I would like as result a new table that subtracts UitvoerDatum from 
Afsluitdatum, and when the result is within 365 days, i need a "1" and when 
the result is more then 365 days, i need a "0".

So the result is:

patientnr         days      value
01234567       334         1
09876543       379         0

Normally i do this in Excell, but i would like to do everything in access 
and not part in access and part in excell.





More information about the AccessD mailing list