A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Find records where value is out of a range



 
 
Thread Tools Display Modes
  #1  
Old July 6th, 2009, 08:11 PM posted to microsoft.public.access
Chuck W[_2_]
external usenet poster
 
Posts: 98
Default Find records where value is out of a range

Hi,

I have three date fields with values in text format that I cannot change.
They appears a 03012009, 04142009 etc. The three fields are AdmitDate,
DischargeDate and ServiceDate. I want to identify all records in which the
service date is not between the admit and discharge date. So if I have a
service date of 05102009 an admit date of 03012009 and a discharge date of
04142009, the service date is out of range and I want it to appear in my
query. Can someone help?

Thanks,

  #2  
Old July 6th, 2009, 08:37 PM posted to microsoft.public.access
Arvin Meyer [MVP][_2_]
external usenet poster
 
Posts: 2,310
Default Find records where value is out of a range

Something like this ought to do it:

SELECT IDField, AdmitDate, DischargeDate, ServiceDate
FROM tblMyData
WHERE [ServiceDate][AdmitDate] Or [ServiceDate][DischargeDate]
ORDER BY IDField;
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


"Chuck W" wrote in message
...
Hi,

I have three date fields with values in text format that I cannot change.
They appears a 03012009, 04142009 etc. The three fields are AdmitDate,
DischargeDate and ServiceDate. I want to identify all records in which
the
service date is not between the admit and discharge date. So if I have a
service date of 05102009 an admit date of 03012009 and a discharge date of
04142009, the service date is out of range and I want it to appear in my
query. Can someone help?

Thanks,



  #3  
Old July 6th, 2009, 08:45 PM posted to microsoft.public.access
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default Find records where value is out of a range

"Chuck W" wrote in message
...
Hi,

I have three date fields with values in text format that I cannot change.
They appears a 03012009, 04142009 etc. The three fields are AdmitDate,
DischargeDate and ServiceDate. I want to identify all records in which
the
service date is not between the admit and discharge date. So if I have a
service date of 05102009 an admit date of 03012009 and a discharge date of
04142009, the service date is out of range and I want it to appear in my
query. Can someone help?



Assuming (1) the fields are always 8 digits in "mmddyyyy" format, and (2)
there are no Nulls in these fields, and (3) DischargeDate is always on or
after AdmitDate, then you might use a WHERE clause like this:

WHERE Not (CDate(Format(ServiceDate, "00/00/0000")) Between
CDate(Format(AdmitDate, "00/00/0000"))
And CDate(Format(DischargeDate, "00/00/0000")))


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

  #4  
Old July 6th, 2009, 08:47 PM posted to microsoft.public.access
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default Find records where value is out of a range

"Arvin Meyer [MVP]" wrote in message
...
Something like this ought to do it:

SELECT IDField, AdmitDate, DischargeDate, ServiceDate
FROM tblMyData
WHERE [ServiceDate][AdmitDate] Or [ServiceDate][DischargeDate]
ORDER BY IDField;



That won't work if the dates are stored in text fields, as Chuck said they
were, Arvin.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:44 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.