PC Review


Reply
Thread Tools Rate Thread

date filters

 
 
Pedro Lerma
Guest
Posts: n/a
 
      15th Feb 2006
I want to do a filter by ages from query, I have as fields "birthday" and
"today", however when I write for example, on field_from_age(0) and
field_until_age(3), my query filter show me person that have 1,2,3,15,17,
years old.
Someone can helpme???
This is my WHERE CODE:

WHERE ((((([consultas].[fecha]/365))-(([paciente].[fecha de
nacimiento]/365))) between [edad1] And [edad2]));

consulta=table name
fecha=date
paciente=date
fecha de nacimiento=birthday
edad1=age1
edad2=age2
thanks and I'm sorry my english isn't very well
Pedro


 
Reply With Quote
 
 
 
 
John Vinson
Guest
Posts: n/a
 
      16th Feb 2006
On Wed, 15 Feb 2006 17:21:50 -0600, "Pedro Lerma"
<(E-Mail Removed)> wrote:

>I want to do a filter by ages from query, I have as fields "birthday" and
>"today", however when I write for example, on field_from_age(0) and
>field_until_age(3), my query filter show me person that have 1,2,3,15,17,
>years old.
>Someone can helpme???
>This is my WHERE CODE:
>
>WHERE ((((([consultas].[fecha]/365))-(([paciente].[fecha de
>nacimiento]/365))) between [edad1] And [edad2]));
>
>consulta=table name
>fecha=date
>paciente=date
>fecha de nacimiento=birthday
>edad1=age1
>edad2=age2
>thanks and I'm sorry my english isn't very well
>Pedro
>


There is an easier way to calculate age.

In a vacant Field cell in the query type

Edad: DateDiff("yyyy", [paciente].[fecha de nacimiento],
[consultas].[fecha]) - IIF(Format([paciente].[fecha de nacimiento],
"mmdd") > Format([consultas].[fecha], 1, 0)

Put a criterion on this of

BETWEEN [edad1] AND [edad2]

You may need to change the arguments to the DateDiff or Format
function - I don't have the Spanish version of Access so I'm not sure
if the arguments change. Buen suerte!

John W. Vinson[MVP]
 
Reply With Quote
 
John Vinson
Guest
Posts: n/a
 
      16th Feb 2006
On Thu, 16 Feb 2006 08:45:31 -0600, "Pedro Lerma"
<(E-Mail Removed)> wrote:

>My query follow giving me a missing results, I'm attaching the results when
>I typing from 1 year until 2 year
>This is my query
>


Try running the query with no criteria at all. Does it give correct
(or at least reasonable) values for edad?

John W. Vinson[MVP]
 
Reply With Quote
 
John Vinson
Guest
Posts: n/a
 
      17th Feb 2006
On Thu, 16 Feb 2006 17:21:56 -0600, "Pedro Lerma"
<(E-Mail Removed)> wrote:

>Yes it give correct values without Between command, may be fieldīs
>propieties for edad field???
>see attachment


Please don't post binary attachments - many people with dialup
connections find that they slow down the newsgroup very badly!

I don't know why, but it appears that the [edad] field is being
treated as Text. Try changing the Where clause to

WHERE (((CInt(DateDiff("yyyy",([paciente].[fecha de
nacimiento]),([consultas].[fecha]))-IIf(Format([paciente].[fecha de
nacimiento],"mmdd")>Format([consultas].[fecha]),1,0))) Between [edad1]
And [edad2]));


John W. Vinson[MVP]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access 2007: Query; Date Filters; After. Error: Includes date ty Stephen Microsoft Access 0 9th Jul 2009 04:32 PM
Pivot Table filters, especially DATE filters chris Microsoft Excel Worksheet Functions 0 27th Aug 2008 04:33 AM
Reports with date filters =?Utf-8?B?SmFC?= Microsoft Access Reports 1 5th Sep 2006 02:29 PM
date filters in query cquinn Microsoft Access Queries 1 15th Dec 2005 02:08 AM
RE: Task Due Date Filters =?Utf-8?B?SW5iYXI=?= Microsoft Outlook 0 24th Aug 2004 11:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:19 AM.