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 » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

datediff



 
 
Thread Tools Display Modes
  #1  
Old July 11th, 2007, 09:46 PM posted to microsoft.public.access.reports
greenbg via AccessMonster.com
external usenet poster
 
Posts: 14
Default datediff

hi
I am trying to get a list of name who's birthday is 35 of days away. I have
build a query with all of the information the I need. Under the field birth I
enter the following criteria:
IIf(DateDiff("d",[birth],Date())=35,[TITLE]+" "+[LNAME]," ")

I get an error 3464 (Data Type Mismatch in criteria expression)

In my table Birth is setup the following way:
Date/Time
Medium Date

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ports/200707/1

  #2  
Old July 11th, 2007, 10:24 PM posted to microsoft.public.access.reports
fredg
external usenet poster
 
Posts: 4,386
Default datediff

On Wed, 11 Jul 2007 20:46:00 GMT, greenbg via AccessMonster.com wrote:

hi
I am trying to get a list of name who's birthday is 35 of days away. I have
build a query with all of the information the I need. Under the field birth I
enter the following criteria:
IIf(DateDiff("d",[birth],Date())=35,[TITLE]+" "+[LNAME]," ")

I get an error 3464 (Data Type Mismatch in criteria expression)

In my table Birth is setup the following way:
Date/Time
Medium Date


The problem with your expression is that it is counting the days
between the date of birth and today's date, whereas you wish to count
the number of days between the month and day of birth (not including
the birth year), and today's month and day.

By the way, the Ampersand (&) is the suggested symbol to concatenate
string data, not the plus (+) symbol.

WhoseBirthday:IIf(DateDiff("d",Format([Birth],"mm/dd"),Format(Date(),"mm/dd"))
Between 0 and 35, [TITLE] & " " & [LNAME]," ")

The above will return all the records. Only the records within 35 days
will include a Title and Name.

A better method, using the query, is to have a new column...
DaysToBirthdayateDiff("d",Format([Birth],"mm/dd"),Format(Date(),"mm/dd"))

as criteria on this column, write:
Between 0 and 35

Then in a new column, write:
WhoesBirthday:[TITLE] & " " & [LNAME]

Only those persons whose birthday falls within 35 days will be
returned by the query.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #3  
Old July 12th, 2007, 08:38 PM posted to microsoft.public.access.reports
greenbg via AccessMonster.com
external usenet poster
 
Posts: 14
Default datediff

fredg
Is there any way that I can get date range without adding the Title an name??
??

fredg wrote:
hi
I am trying to get a list of name who's birthday is 35 of days away. I have

[quoted text clipped - 7 lines]
Date/Time
Medium Date


The problem with your expression is that it is counting the days
between the date of birth and today's date, whereas you wish to count
the number of days between the month and day of birth (not including
the birth year), and today's month and day.

By the way, the Ampersand (&) is the suggested symbol to concatenate
string data, not the plus (+) symbol.

WhoseBirthday:IIf(DateDiff("d",Format([Birth],"mm/dd"),Format(Date(),"mm/dd"))
Between 0 and 35, [TITLE] & " " & [LNAME]," ")

The above will return all the records. Only the records within 35 days
will include a Title and Name.

A better method, using the query, is to have a new column...
DaysToBirthdayateDiff("d",Format([Birth],"mm/dd"),Format(Date(),"mm/dd"))

as criteria on this column, write:
Between 0 and 35

Then in a new column, write:
WhoesBirthday:[TITLE] & " " & [LNAME]

Only those persons whose birthday falls within 35 days will be
returned by the query.


--
bg

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ports/200707/1

  #4  
Old July 12th, 2007, 08:50 PM posted to microsoft.public.access.reports
fredg
external usenet poster
 
Posts: 4,386
Default datediff

On Thu, 12 Jul 2007 19:38:03 GMT, greenbg via AccessMonster.com wrote:

fredg
Is there any way that I can get date range without adding the Title an name??
??

fredg wrote:
hi
I am trying to get a list of name who's birthday is 35 of days away. I have

[quoted text clipped - 7 lines]
Date/Time
Medium Date


The problem with your expression is that it is counting the days
between the date of birth and today's date, whereas you wish to count
the number of days between the month and day of birth (not including
the birth year), and today's month and day.

By the way, the Ampersand (&) is the suggested symbol to concatenate
string data, not the plus (+) symbol.

WhoseBirthday:IIf(DateDiff("d",Format([Birth],"mm/dd"),Format(Date(),"mm/dd"))
Between 0 and 35, [TITLE] & " " & [LNAME]," ")

The above will return all the records. Only the records within 35 days
will include a Title and Name.

A better method, using the query, is to have a new column...
DaysToBirthdayateDiff("d",Format([Birth],"mm/dd"),Format(Date(),"mm/dd"))

as criteria on this column, write:
Between 0 and 35

Then in a new column, write:
WhoesBirthday:[TITLE] & " " & [LNAME]

Only those persons whose birthday falls within 35 days will be
returned by the query.


I'm afraid I don't understand this question.
Try again, with an example of the result you wish.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #5  
Old July 12th, 2007, 09:30 PM posted to microsoft.public.access.reports
greenbg via AccessMonster.com
external usenet poster
 
Posts: 14
Default datediff

I would like to use the datediff without the iif function. I tried to remove
the iif funcution and added TITLE and LNAME FIELD to my query and it can up
empty. I place the datediff function in the BIRTH field..

fredg wrote:
fredg
Is there any way that I can get date range without adding the Title an name??

[quoted text clipped - 31 lines]
Only those persons whose birthday falls within 35 days will be
returned by the query.


I'm afraid I don't understand this question.
Try again, with an example of the result you wish.


--
bg

Message posted via http://www.accessmonster.com

 




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 06:52 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.