473,326 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Pull current months data

how do you pull the current months data without having to manually
input the date each time?

Oct 19 '06 #1
5 2918

RandyG wrote:
how do you pull the current months data without having to manually
input the date each time?
Something like

SELECT...
FROM ...
WHERE Month(tbl.Datefield)=Month(Date()) And
Year(tbl.DateField)=Year(Date())

Oct 19 '06 #2
that worked thanks.

Now what i just noticed, im pulling information for month end reports
that shows data from years prior to the current report month. How can i
pull the current months information and prior report information?


On Oct 19, 3:00 pm, "RandyG" <astr...@gmail.comwrote:
how do you pull the current months data without having to manually
input the date each time?
Oct 19 '06 #3

RandyG wrote:
that worked thanks.

Now what i just noticed, im pulling information for month end reports
that shows data from years prior to the current report month. How can i
pull the current months information and prior report information?


On Oct 19, 3:00 pm, "RandyG" <astr...@gmail.comwrote:
how do you pull the current months data without having to manually
input the date each time?
I don't understand. If you have a filter for Year and for Month you
should be OK. post your SQL.

Oct 20 '06 #4
RandyG wrote:
that worked thanks.

Now what i just noticed, im pulling information for month end reports
that shows data from years prior to the current report month. How can i
pull the current months information and prior report information?


On Oct 19, 3:00 pm, "RandyG" <astr...@gmail.comwrote:
how do you pull the current months data without having to manually
input the date each time?
SELECT IIf(DateField BETWEEN MonthStartDate AND MonthEndDate,
DataValueField, 0) AS MonthData FROM tblX WHERE DateField BETWEEN
PeriodStartDate AND PeriodEndDate;

Any DateField value outside the month will return 0 for MonthData, so
summing all the MonthData values will give you the sum for that month
even though the query returns all the records within the period.
Replace DataValueField with a 1 if a count rather than a sum is needed.

Note that there should be no time portion stored in the date fields
when using BETWEEN, otherwise you'll need to add a day to the second
date. For a given date, say dtX, the beginning of the month containing
dtX can be found using DateSerial(Year(dtX), Month(dtX), 1) and the end
of the month containing dtX can be found using DateSerial(Year(dtX),
Month(dtX) + 1, 0).

I hope this helps you get the information you need.

James A. Fortune
CD********@FortuneJames.com

That time of year thou may'st in me behold
When yellow leaves, or none, or few, do hang
Upon those boughs which shake against the cold
Bare ruin'd choirs, where late the sweet birds sang.
-- Shakespeare, Sonnet 73

Oct 20 '06 #5
RandyG wrote:
how do you pull the current months data without having to manually
input the date each time?
This would be more efficient than using Month() if your date field is indexed.

SELECT *
FROM TableName
WHERE DateField >= DateSerial(Year(Date()), Month(Date()), 1)
AND DateField < DateSerial(Year(Date()), Month(Date()) + 1, 0)
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Oct 20 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Caesar | last post by:
Hi, I'm wondering if anyone here can point me in the right direction. My host does not provide php, and so I need to pull this data from another server that does support such scripting. Help?...
5
by: Julia Baresch | last post by:
Hi everyone, I haven't found any reference to this problem on this group or in Access 97 help. I hope someone here knows this - probably a simple thing, but not obvious. I designed a query to...
1
by: Nick J | last post by:
Hi, I have a command button, when I press it I would like it to find the record I have specified in a text box on the current form and to pull fields such as Address 1 and Address 2 from another...
2
by: Nick | last post by:
What I want to do is have 2 pull down lists, for example a state pull down list and a city pull down list. What I would like to have done is when you select a state from the state pull down list...
3
by: jjgardner3.web | last post by:
Hello I have a very simple xml file: <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="./status.xsl"?> <IEC> <Workstation> <Hostname>HOSTNAME</Hostname>...
14
by: Tina | last post by:
My employer tracks productivity/performance of clinicians (how much they bill) each week, its averages for the month, and the 6 months. These averages are compared to their expected productivity....
4
by: sparks | last post by:
We have a new project here, one that I have never tried maybe its easy I don't know yet. We have people that have records dating back over 5 yrs on a sql server. We have to build an access 2003...
3
by: remya1000 | last post by:
i'm using ASP with MSAccess as database. i have two buttons and two textbox in my page. when i press my first button (First month) i need to display the current month in one textbox and last one...
11
by: Harlin Seritt | last post by:
Is there a module that can pull str values for say the last 3 months? Something like: print lastMonths(3) Thanks
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.