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  

current month



 
 
Thread Tools Display Modes
  #1  
Old November 26th, 2008, 05:49 PM posted to microsoft.public.access.queries
John
external usenet poster
 
Posts: 2,649
Default current month

I have a query that has the date and time as 11/26/2008 12:42:33pm, what I
want to do is pull the current months data using the system date/time. I've
tried a few different things and I only get partial data, but if I put in
#11/1/2008# and #12/1/2008# I get the correct records. I don't want to

have to put in the date range but use the systems date to determine the month.

Thanks in advance
  #2  
Old November 26th, 2008, 05:55 PM posted to microsoft.public.access.queries
Duane Hookom
external usenet poster
 
Posts: 7,177
Default current month

You could use something like:
WHERE Format([Date Field], "yyyymm") = Format(Date(), "yyyymm")
--
Duane Hookom
Microsoft Access MVP


"John" wrote:

I have a query that has the date and time as 11/26/2008 12:42:33pm, what I
want to do is pull the current months data using the system date/time. I've
tried a few different things and I only get partial data, but if I put in
#11/1/2008# and #12/1/2008# I get the correct records. I don't want to

have to put in the date range but use the systems date to determine the month.

Thanks in advance

  #3  
Old November 26th, 2008, 06:03 PM posted to microsoft.public.access.queries
Rick Brandt
external usenet poster
 
Posts: 4,354
Default current month

On Wed, 26 Nov 2008 09:49:00 -0800, John wrote:

I have a query that has the date and time as 11/26/2008 12:42:33pm, what
I want to do is pull the current months data using the system date/time.
I've tried a few different things and I only get partial data, but if I
put in
#11/1/2008# and #12/1/2008# I get the correct records. I don't want to

have to put in the date range but use the systems date to determine the
month.

Thanks in advance


SELECT *
FROM TableName
WHERE DateField = DateSerial(Year(Date()), Month(Date()), 1)
AND DateField DateSerial(Year(Date()), Month(Date())+ 1, 1)



--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
  #4  
Old November 26th, 2008, 06:07 PM posted to microsoft.public.access.queries
John
external usenet poster
 
Posts: 2,649
Default current month

I tried that but get an syntax error.

"Duane Hookom" wrote:

You could use something like:
WHERE Format([Date Field], "yyyymm") = Format(Date(), "yyyymm")
--
Duane Hookom
Microsoft Access MVP


"John" wrote:

I have a query that has the date and time as 11/26/2008 12:42:33pm, what I
want to do is pull the current months data using the system date/time. I've
tried a few different things and I only get partial data, but if I put in
#11/1/2008# and #12/1/2008# I get the correct records. I don't want to

have to put in the date range but use the systems date to determine the month.

Thanks in advance

  #5  
Old November 26th, 2008, 06:07 PM posted to microsoft.public.access.queries
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default current month

John

So, if you are only interested in the "current month"'s data, and if today
is only the 26th, it seems like the only time you'd get the entire month's
data is if you ran this query on the last day of the month.

If you're out that day, or it falls on a weekend, or you forget, or ...,
you'd be in a new month. How do you plan to get "last month's" data, if
that's what you need?

Regards

Jeff Boyce
Microsoft Office/Access MVP

"John" wrote in message
...
I have a query that has the date and time as 11/26/2008 12:42:33pm, what I
want to do is pull the current months data using the system date/time.
I've
tried a few different things and I only get partial data, but if I put in
#11/1/2008# and #12/1/2008# I get the correct records. I don't want to

have to put in the date range but use the systems date to determine the
month.

Thanks in advance



  #6  
Old November 26th, 2008, 06:22 PM posted to microsoft.public.access.queries
Marshall Barton
external usenet poster
 
Posts: 5,361
Default current month

John wrote:

I have a query that has the date and time as 11/26/2008 12:42:33pm, what I
want to do is pull the current months data using the system date/time. I've
tried a few different things and I only get partial data, but if I put in
#11/1/2008# and #12/1/2008# I get the correct records. I don't want to

have to put in the date range but use the systems date to determine the month.



Add a calculated field to the query:

field/expression Month(thedatefield)
criteria =Month(Date())

--
Marsh
MVP [MS Access]
  #7  
Old November 26th, 2008, 06:30 PM posted to microsoft.public.access.queries
John
external usenet poster
 
Posts: 2,649
Default current month

Jeff,

That is a good point, My first attempt I wanted a text box on a form that I
could input my date range into and then have the query run. That would have
been Ideal.

"Jeff Boyce" wrote:

John

So, if you are only interested in the "current month"'s data, and if today
is only the 26th, it seems like the only time you'd get the entire month's
data is if you ran this query on the last day of the month.

If you're out that day, or it falls on a weekend, or you forget, or ...,
you'd be in a new month. How do you plan to get "last month's" data, if
that's what you need?

Regards

Jeff Boyce
Microsoft Office/Access MVP

"John" wrote in message
...
I have a query that has the date and time as 11/26/2008 12:42:33pm, what I
want to do is pull the current months data using the system date/time.
I've
tried a few different things and I only get partial data, but if I put in
#11/1/2008# and #12/1/2008# I get the correct records. I don't want to

have to put in the date range but use the systems date to determine the
month.

Thanks in advance




  #8  
Old November 26th, 2008, 07:41 PM posted to microsoft.public.access.queries
Duane Hookom
external usenet poster
 
Posts: 7,177
Default current month

When you have a syntax error you should reply back with your full SQL view.
It's a bit difficult to troubleshoot something we can see.
--
Duane Hookom
Microsoft Access MVP


"John" wrote:

I tried that but get an syntax error.

"Duane Hookom" wrote:

You could use something like:
WHERE Format([Date Field], "yyyymm") = Format(Date(), "yyyymm")
--
Duane Hookom
Microsoft Access MVP


"John" wrote:

I have a query that has the date and time as 11/26/2008 12:42:33pm, what I
want to do is pull the current months data using the system date/time. I've
tried a few different things and I only get partial data, but if I put in
#11/1/2008# and #12/1/2008# I get the correct records. I don't want to
have to put in the date range but use the systems date to determine the month.

Thanks in advance

  #9  
Old November 26th, 2008, 07:58 PM posted to microsoft.public.access.queries
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default current month

John

I'd suggest two controls on the form, [StartDate] and [EndDate], so your
query can point to those values in a "Between ... And ..." statement.

Regards

Jeff Boyce
Microsoft Office/Access MVP

"John" wrote in message
...
Jeff,

That is a good point, My first attempt I wanted a text box on a form that
I
could input my date range into and then have the query run. That would
have
been Ideal.

"Jeff Boyce" wrote:

John

So, if you are only interested in the "current month"'s data, and if
today
is only the 26th, it seems like the only time you'd get the entire
month's
data is if you ran this query on the last day of the month.

If you're out that day, or it falls on a weekend, or you forget, or ...,
you'd be in a new month. How do you plan to get "last month's" data, if
that's what you need?

Regards

Jeff Boyce
Microsoft Office/Access MVP

"John" wrote in message
...
I have a query that has the date and time as 11/26/2008 12:42:33pm, what
I
want to do is pull the current months data using the system date/time.
I've
tried a few different things and I only get partial data, but if I put
in
#11/1/2008# and #12/1/2008# I get the correct records. I don't want
to
have to put in the date range but use the systems date to determine the
month.

Thanks in advance






  #10  
Old November 27th, 2008, 08:35 AM posted to microsoft.public.access.queries
KatyTK
external usenet poster
 
Posts: 1
Default current month

Hi John.

Try the following as the criteria in your query: Year([Name of column]) =
Year(Now()) And Month([Name of column]) = Month(Now())

Hope this works OK for you.

Katy

"John" wrote:

I have a query that has the date and time as 11/26/2008 12:42:33pm, what I
want to do is pull the current months data using the system date/time. I've
tried a few different things and I only get partial data, but if I put in
#11/1/2008# and #12/1/2008# I get the correct records. I don't want to

have to put in the date range but use the systems date to determine the month.

Thanks in advance

 




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:42 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.