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

A spin on a common question. DateAdd



 
 
Thread Tools Display Modes
  #1  
Old April 23rd, 2010, 01:59 AM posted to microsoft.public.access.queries
Flopbot
external usenet poster
 
Posts: 60
Default A spin on a common question. DateAdd

This is a spin on a common question. I have a query with a field labeled:
Day: Format([Date],"ddd, mm/dd/yy"). I need it to display the day along with
the date (Sat, 4/24/210) ~ works great. I’m trying to retrieve all records
for one month out by using: DateAdd("d",+31,Date()) ~ not working. The
only thing I can think of is that the format is somehow messing it up. Would
this be the case? Thank you in advance!
  #2  
Old April 23rd, 2010, 03:18 AM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default A spin on a common question. DateAdd

On Thu, 22 Apr 2010 17:59:01 -0700, Flopbot
wrote:

This is a spin on a common question. I have a query with a field labeled:
Day: Format([Date],"ddd, mm/dd/yy"). I need it to display the day along with
the date (Sat, 4/24/210) ~ works great. Im trying to retrieve all records
for one month out by using: DateAdd("d",+31,Date()) ~ not working. The
only thing I can think of is that the format is somehow messing it up. Would
this be the case? Thank you in advance!


The Format() function takes its argument and turns it into a string. DateAdd()
works with Date/Time values (actually stored as a number), not with strings!

Apply the criterion to the (badly misnamed, Date is a reserved word and will
cause problems) [Date] field, not to the text string [Day].

Note that your criterion will not return all records "for one month out" - it
will return all records PAST 31 days from today. To get the records between
today's date and a month from today, use a criterion on Date() of

= Date() AND = DateAdd("m", 1, Date())


--

John W. Vinson [MVP]
  #3  
Old April 23rd, 2010, 11:33 PM posted to microsoft.public.access.queries
Flopbot
external usenet poster
 
Posts: 60
Default A spin on a common question. DateAdd

Thank you John.

Good point about the name. I’ve changed it to Event Date. Also, I
simplified by query based on your suggestions and changed the criterion.
Basically, the reason for the query is to include the information as a table
imbedded in an email. I’m using word’s mail merge function to create the
email and want to use the “Insert Database Wizard” located on word’s
“Database Toolbox” to insert the table. However, this wizard doesn’t
recognize forms or reports. Also, it doesn’t recognize any queries with
something unique (expressions, Dept: Department, anything other than a
simple label) in the Field row. Due to size & display requirements in the
email, I can’t create such a simple query. After much experimenting, the
only workaround I found was to link the query to a form and do any formatting
of date/field names there. Then, by displaying it in datasheet view, I can
cut/paste the table into an email. It’s not as slick as I hoped, but it
still shaves several hours off my past method.

Thank you for your advice!

Chris


"John W. Vinson" wrote:

On Thu, 22 Apr 2010 17:59:01 -0700, Flopbot
wrote:

This is a spin on a common question. I have a query with a field labeled:
Day: Format([Date],"ddd, mm/dd/yy"). I need it to display the day along with
the date (Sat, 4/24/210) ~ works great. I’m trying to retrieve all records
for one month out by using: DateAdd("d",+31,Date()) ~ not working. The
only thing I can think of is that the format is somehow messing it up. Would
this be the case? Thank you in advance!


The Format() function takes its argument and turns it into a string. DateAdd()
works with Date/Time values (actually stored as a number), not with strings!

Apply the criterion to the (badly misnamed, Date is a reserved word and will
cause problems) [Date] field, not to the text string [Day].

Note that your criterion will not return all records "for one month out" - it
will return all records PAST 31 days from today. To get the records between
today's date and a month from today, use a criterion on Date() of

= Date() AND = DateAdd("m", 1, Date())


--

John W. Vinson [MVP]
.

 




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 01:29 PM.


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