Display 4 weeks of data

Hello all,

I am trying to create a query in which data is displayed for the current 
month beginning with the first day of the week, first week of the month and 
ending with the last day of the week, last week of the month.

In example: Today is Friday June 1, 2007 but the first day of the week would 
be Sunday, May 27, 2007.  I would like the query to show data between 
5/27/2007 through 6/30/2007 -OR- 4/29/2007 through 6/2/2007 for the previous 
month...

Does anyone have any ideas? 
0
Utf
7/3/2007 10:26:01 PM
access.queries 6343 articles. 1 followers. Follow

8 Replies
1394 Views

Similar Articles

[PageSpeed] 22

First day of the current month is DateSerial(Year(Date()), Month(Date()), 1)

Last day of the current month is DateSerial(Year(Date()), Month(Date()) + 1, 
0)

Sunday of the current week is DateAdd("d", 1 - Weekday(Date()), Date()), 
which is the same as Date() - Weekday(Date()) + 1

-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"A McKay" <AMcKay@discussions.microsoft.com> wrote in message 
news:F2512C44-2B03-4963-B84D-E2C009B34343@microsoft.com...
> Hello all,
>
> I am trying to create a query in which data is displayed for the current
> month beginning with the first day of the week, first week of the month 
> and
> ending with the last day of the week, last week of the month.
>
> In example: Today is Friday June 1, 2007 but the first day of the week 
> would
> be Sunday, May 27, 2007.  I would like the query to show data between
> 5/27/2007 through 6/30/2007 -OR- 4/29/2007 through 6/2/2007 for the 
> previous
> month...
>
> Does anyone have any ideas? 


0
Douglas
7/3/2007 11:01:01 PM
On Tue, 3 Jul 2007 15:26:01 -0700, A McKay <AMcKay@discussions.microsoft.com>
wrote:

>Hello all,
>
>I am trying to create a query in which data is displayed for the current 
>month beginning with the first day of the week, first week of the month and 
>ending with the last day of the week, last week of the month.
>
>In example: Today is Friday June 1, 2007 but the first day of the week would 
>be Sunday, May 27, 2007.  I would like the query to show data between 
>5/27/2007 through 6/30/2007 -OR- 4/29/2007 through 6/2/2007 for the previous 
>month...
>
>Does anyone have any ideas? 

Use a criterion of

>= DateAdd("d", 1-Weekday(DateSerial(Year(Date()), Month(Date()), 1)), DateSerial(Year(Date()), Month(Date()), 1))
AND  <  DateAdd("d", 1-Weekday(DateSerial(Year(Date()), Month(Date())+1, 1)),
DateSerial(Year(Date()), Month(Date())+1, 1))


             John W. Vinson [MVP]
0
John
7/3/2007 11:17:26 PM
Doug thank you for such a quick response.  What would Sunday of the first 
week of the month be?  Or is there a way of combining the query criteria you 
listed below?  Thanks again...

"Douglas J. Steele" wrote:

> First day of the current month is DateSerial(Year(Date()), Month(Date()), 1)
> 
> Last day of the current month is DateSerial(Year(Date()), Month(Date()) + 1, 
> 0)
> 
> Sunday of the current week is DateAdd("d", 1 - Weekday(Date()), Date()), 
> which is the same as Date() - Weekday(Date()) + 1
> 
> -- 
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
> 
> 
> "A McKay" <AMcKay@discussions.microsoft.com> wrote in message 
> news:F2512C44-2B03-4963-B84D-E2C009B34343@microsoft.com...
> > Hello all,
> >
> > I am trying to create a query in which data is displayed for the current
> > month beginning with the first day of the week, first week of the month 
> > and
> > ending with the last day of the week, last week of the month.
> >
> > In example: Today is Friday June 1, 2007 but the first day of the week 
> > would
> > be Sunday, May 27, 2007.  I would like the query to show data between
> > 5/27/2007 through 6/30/2007 -OR- 4/29/2007 through 6/2/2007 for the 
> > previous
> > month...
> >
> > Does anyone have any ideas? 
> 
> 
> 
0
Utf
7/3/2007 11:54:00 PM
In article <F2512C44-2B03-4963-B84D-E2C009B34343@microsoft.com>, 
AMcKay@discussions.microsoft.com says...
> Hello all,
> 
> I am trying to create a query in which data is displayed for the current 
> month beginning with the first day of the week, first week of the month and 
> ending with the last day of the week, last week of the month.
> 
> In example: Today is Friday June 1, 2007 but the first day of the week would 
> be Sunday, May 27, 2007.  I would like the query to show data between 
> 5/27/2007 through 6/30/2007 -OR- 4/29/2007 through 6/2/2007 for the previous 
> month...
> 
> Does anyone have any ideas? 
> 

If I understand the problem, you want to retrieve records
between the first day of the week that contains the first day
of the month and the last day of the week that contains 
the last day of the month.

This is not pretty, but it seems to work. Test it using the
Northwind sample database.

SELECT   Orders.OrderDate,
         SUM([Order Subtotals].Subtotal)  AS [Daily Sales]
FROM     Orders
         INNER JOIN [Order Subtotals]
           ON Orders.OrderID = [Order Subtotals].OrderID
WHERE    Orders.OrderDate 
BETWEEN DATEADD("ww",DATEDIFF("ww",1,[Enter 1st of month:]), 1)
   AND DATEADD("ww",DATEDIFF("ww",1,DATEADD("m",
         DATEDIFF("m",1,[Enter 1st of month:]),1)),1) + 6
GROUP BY Orders.OrderDate;
0
Michael
7/4/2007 12:25:48 AM
John, thanks for your quick response too.  I worked your criterion and it 
worked, however it stopped at the friday of the last whole week.  For 
example, it stopped at Friday, July 28 instead of August 4th.  I was able to 
adjust the criterion to give me to the last day of the month which will work 
just fine unless you can come up with an idea to include the last incomplete 
week...

Thanks again for your help

"John W. Vinson" wrote:

> On Tue, 3 Jul 2007 15:26:01 -0700, A McKay <AMcKay@discussions.microsoft.com>
> wrote:
> 
> >Hello all,
> >
> >I am trying to create a query in which data is displayed for the current 
> >month beginning with the first day of the week, first week of the month and 
> >ending with the last day of the week, last week of the month.
> >
> >In example: Today is Friday June 1, 2007 but the first day of the week would 
> >be Sunday, May 27, 2007.  I would like the query to show data between 
> >5/27/2007 through 6/30/2007 -OR- 4/29/2007 through 6/2/2007 for the previous 
> >month...
> >
> >Does anyone have any ideas? 
> 
> Use a criterion of
> 
> >= DateAdd("d", 1-Weekday(DateSerial(Year(Date()), Month(Date()), 1)), DateSerial(Year(Date()), Month(Date()), 1))
> AND  <  DateAdd("d", 1-Weekday(DateSerial(Year(Date()), Month(Date())+1, 1)),
> DateSerial(Year(Date()), Month(Date())+1, 1))
> 
> 
>              John W. Vinson [MVP]
> 
0
Utf
7/4/2007 12:32:03 AM
On Tue, 3 Jul 2007 17:32:03 -0700, A McKay <AMcKay@discussions.microsoft.com>
wrote:

>John, thanks for your quick response too.  I worked your criterion and it 
>worked, however it stopped at the friday of the last whole week.  For 
>example, it stopped at Friday, July 28 instead of August 4th.  I was able to 
>adjust the criterion to give me to the last day of the month which will work 
>just fine unless you can come up with an idea to include the last incomplete 
>week...

Note that some months have FIVE weeks not four. Try

>= DateAdd("d", 1-Weekday(DateSerial(Year(Date()), Month(Date()), 1)), DateSerial(Year(Date()), Month(Date()), 1))
AND  <  DateAdd("d", 8-Weekday(DateSerial(Year(Date()), Month(Date())+1, 1)),
DateSerial(Year(Date()), Month(Date())+1, 1))

changing a 1 to an 8 in the end of month criterion.

             John W. Vinson [MVP]
0
John
7/4/2007 12:40:29 AM
Sunday preceding first day of current month:

DateAdd("d", 1 - Weekday(DateSerial(Year(Date()), Month(Date()), 1)), 
DateSerial(Year(Date()), Month(Date()), 1))

-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"A McKay" <AMcKay@discussions.microsoft.com> wrote in message 
news:084DA76F-B6D8-4B5A-B316-0980EF0FBA6B@microsoft.com...
> Doug thank you for such a quick response.  What would Sunday of the first
> week of the month be?  Or is there a way of combining the query criteria 
> you
> listed below?  Thanks again...
>
> "Douglas J. Steele" wrote:
>
>> First day of the current month is DateSerial(Year(Date()), Month(Date()), 
>> 1)
>>
>> Last day of the current month is DateSerial(Year(Date()), Month(Date()) + 
>> 1,
>> 0)
>>
>> Sunday of the current week is DateAdd("d", 1 - Weekday(Date()), Date()),
>> which is the same as Date() - Weekday(Date()) + 1
>>
>> -- 
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no private e-mails, please)
>>
>>
>> "A McKay" <AMcKay@discussions.microsoft.com> wrote in message
>> news:F2512C44-2B03-4963-B84D-E2C009B34343@microsoft.com...
>> > Hello all,
>> >
>> > I am trying to create a query in which data is displayed for the 
>> > current
>> > month beginning with the first day of the week, first week of the month
>> > and
>> > ending with the last day of the week, last week of the month.
>> >
>> > In example: Today is Friday June 1, 2007 but the first day of the week
>> > would
>> > be Sunday, May 27, 2007.  I would like the query to show data between
>> > 5/27/2007 through 6/30/2007 -OR- 4/29/2007 through 6/2/2007 for the
>> > previous
>> > month...
>> >
>> > Does anyone have any ideas?
>>
>>
>> 


0
Douglas
7/4/2007 8:56:36 PM
Thanks again for your help

"Douglas J. Steele" wrote:

> Sunday preceding first day of current month:
> 
> DateAdd("d", 1 - Weekday(DateSerial(Year(Date()), Month(Date()), 1)), 
> DateSerial(Year(Date()), Month(Date()), 1))
> 
> -- 
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
> 
> 
> "A McKay" <AMcKay@discussions.microsoft.com> wrote in message 
> news:084DA76F-B6D8-4B5A-B316-0980EF0FBA6B@microsoft.com...
> > Doug thank you for such a quick response.  What would Sunday of the first
> > week of the month be?  Or is there a way of combining the query criteria 
> > you
> > listed below?  Thanks again...
> >
> > "Douglas J. Steele" wrote:
> >
> >> First day of the current month is DateSerial(Year(Date()), Month(Date()), 
> >> 1)
> >>
> >> Last day of the current month is DateSerial(Year(Date()), Month(Date()) + 
> >> 1,
> >> 0)
> >>
> >> Sunday of the current week is DateAdd("d", 1 - Weekday(Date()), Date()),
> >> which is the same as Date() - Weekday(Date()) + 1
> >>
> >> -- 
> >> Doug Steele, Microsoft Access MVP
> >> http://I.Am/DougSteele
> >> (no private e-mails, please)
> >>
> >>
> >> "A McKay" <AMcKay@discussions.microsoft.com> wrote in message
> >> news:F2512C44-2B03-4963-B84D-E2C009B34343@microsoft.com...
> >> > Hello all,
> >> >
> >> > I am trying to create a query in which data is displayed for the 
> >> > current
> >> > month beginning with the first day of the week, first week of the month
> >> > and
> >> > ending with the last day of the week, last week of the month.
> >> >
> >> > In example: Today is Friday June 1, 2007 but the first day of the week
> >> > would
> >> > be Sunday, May 27, 2007.  I would like the query to show data between
> >> > 5/27/2007 through 6/30/2007 -OR- 4/29/2007 through 6/2/2007 for the
> >> > previous
> >> > month...
> >> >
> >> > Does anyone have any ideas?
> >>
> >>
> >> 
> 
> 
> 
0
Utf
7/4/2007 10:50:00 PM
Reply:

Similar Artilces:

Acces denied when trying to access offline data after synchro
Hi, I have XP SP2 fresh Installed on my laptop, reinstall crm for outlook with all patches, everything work fine with my crm on my server, i can acces my data with my outlook and also via the web. I do sync and it work fine also. After the sync i automaticly receive a error : Acces denied : You do not have sufficient access rights or privileges to perform this action. I go back online ans it's working online. Never able to access my offline data and getting this message each time. In the registry key i have the 00 already. My CRM security service is strated on the server. The only...

Trying to update data in RMS with a web interface
My project is much more complicated, but I am hoping someone can give me some generic tips and/or code to assist me. I want to update a field in RMS with some data the cashier inputs on an HTML form. For example, if a cashier selects a customer using F7, I want them to press a custom button that brings up an HTML window. That html file will have a form where the cashier will enter some text in a textbox. When the cashier presses Submit, the text in the textbox will be written to the Customer.CustomText1 field. The two major issues are 1) how to pass the Customer.ID to the HTML window ...

Summing Data Series
I have just created a chart, but rather than show each data series individually, it has added them together. Hence the first data series shows the values from Column A of my Sheet correctly, but the second series shows the values from column A PLUS the valus from COlumn B, similarly the third series shows the sum of the values from Columns A, B and C. Why is Excel doing this? I am using Excel XP That is rather strange -- unless, of course, you are creating a stacked column chart, in which case the behavior is as expected. If not, how *exactly* did you create the chart? And, what do...

Consolidating & Labels
When consolidating a bunch of data and checking "Create Links to Sourc Data," everything works fine but it includes a + or minus icon on th left to click on to see all of the values summed (added rows). Now, my question is: Is it possible to have labels on the left of al of these 40 values or so being summed (only seen when consolidated cel is expanded) and have those labels appear directly to the left of thes values from the source files? This would then make it easy to create pivotTable. Thank you -- rhelle -----------------------------------------------------------------------...

Dual Displays
I want to connect my Sharp Aquos flat screen TV to my computer, and see my desktop on both the TV and computer monitor. Windows Vista Home Premium. HP Pavilion a1610n computer. Galaxy GeForce 8400 GS graphics card, outputs: 1-VGA, 1-DVI, and 1-SVGA. There is no HDMI port on the card. I connected a VGA cable between the motherboard "on-board" VGA port and the TV, figuring that I could use that output to work with the TV. The computer monitor is plugged into the GeForce graphics card. Tried the Desktop "Display Setting". It says, the number 2 monitor is "N...

Money Data
I am using Money 2002 (simply because later version don't offer anything new that I need) but I cannot find anyway or option that will allow me to store the data externally. I can store the backup in a variety of places, however, I would like to keep the primary files, and the automatic backup, off the hard drive and unaccessessible to hackers. Does anyone know how this can be done? Thanks You can copy your .mny file to any media you like using the normal Windows tools from My Computer or Windows Explorer. You can also usually backup to these media using browse from within the M...

Display a message box "this entry is a duplicate"
How can I display a message box on a form if the shipment number is a duplicate? I need a message box to pop up when user attempts to tab out of the field. Thank you. Something like: Private Sub txtShipNum_BeforeUpdate(Cancel As Integer) If DCount("*", "MyTable", "ShipNum = '" & Me.txtShipNum & "'") > 0 Then Msgbox Me.txtShipNum & " already exists." Cancel = True End If End Sub This assumes that your text box is named txtShipNum, that the name of the field in table MyTable is ShipNum...

Folder could not be displayed
I am running Windows XP and Outlook Express 6 just fine then one day my husband does something to my computer and his email account won't work. My email is working just fine but in his he cannot open his inbox. It says folder could not be displayed, and when you send and receive it gives you this error message: "An unknown error has occured. Account: 'incoming.verizon.net'. Server:'incoming.verizon.net'.Protocol:POP3, port: 110, Secure(SSL): No, error number: 0x800C013B" If anyone could help me with this I would greatly appreciate it. Thank you T...

how to display values in 3 cells into one cell
Anyone can help me how do I display the 3 separate different values in 3 cells into just one single cell ? thanks so much in advance. Either there was a typo or there's an echo in here. That line should have been: = A1 & " " & B1 & " " & C1 "Bradley Dawson" <bradleydawson@earthlink.net> wrote in message news:l464b.2224$Lk5.2093@newsread3.news.pas.earthlink.net... > In the target cell, type: > > = A1 & B1 & C1 > > where A1, B1, C1 are the cell addresses that you want to concatenate. > > If these have number...

Excel Slooooow. It takes 4 to 6 seconds to perform each input or command
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel I have just installed Excel 2008 on a new installation of Snow Leopard and it does not work properly. It takes ages to register every input or command, like a large Lag. <br><br>EG. each figure or text, input into cells takes 4 seconds from hitting enter to accepting the input. Changing the width of a column takes 6 seconds from letting go of the mouse after dragging to the new width. etc etc. <br><br>I have checked for updates. Any ideas? > I have just installed Excel 2008 on a n...

Printing JUST the Charts, not the data...
Hi, I'm using Excel 2000 and have a number of worksheets with which I've created some charts (all in the same workbook). Is there a way to print the charts that doesn't involve having to highlight each chart individually? I've got some charts in the same worksheet as their source data and some that are on their own page, but that doesn't seem to matter (unless I'm missing something). Any ideas? Thanks, Shane You could use a macro like the following. It prints out each chart sheet, and each embedded chart on each sheet, as if you'd selected each chart a...

How to select & display distinct values
Hello, I need help with a form please. My form has two controls, the first being a combo box. This box should select the company name from a lookup table. The lookup table has only two companies in it, however, they each are repeated several time. Company 1 has about 10 rows, company 2 has 3 rows. I used the query builder and came up with the statement: "SELECT DISTINCT Lktbl_Role_Master.CompanyName FROM Lktbl_Role_Master;" When I run the statement directly from query view, it executes perfectly and returns exactly two rows (one for each company, in a datasheet view) ho...

Display Time in Outlook
The time setting in my Outlook is one hour behind my actual time. I cannot determine how to change the time. Outlook is the only item that is incorrect. Other display times in operating system are correct. Thanks, Jodi ...

file attachment #4
Could anyone suggest how to override the setting that I have in Outlook Express? I try to send a file attachment with my emails and it deletes them when I send the email out. It says OE has deleted the file just in case it has a bug in it.Akkkk! any help would be appreciated. This newsgroup is for support of Outlook 97-2003 from the Office family for Windows PCs. For Outlook Express (OE) support try posting in one of these newsgroups: microsoft.public.inetexplorer.ie4.outlookexpress for OE 4.x microsoft.public.windows.inetexplorer.ie5.outlookexpress for OE 5.x http://support.microsoft.com...

outlook freezes when viewing in day,week, month mode
Hi, WHen I navigate to the calendar function Outlook 'locks up' and does not respond. Waiting for the activity to proccess does not work and i have to close it down and re-open. However, if I change to view to the list mode this doesn't occur. This seems to have started happening only after loading Business Contact Manager. I have reloaded both but still have the same problem. Can anyone help. On 3/8/2010 10:19 PM, GT Query wrote: > Hi, WHen I navigate to the calendar function Outlook 'locks up' and does not > respond. Waiting for the activity to p...

Upsizing with picture data
I am attempting to upsize a database from Access 2003 to SQL Server 2005 Express. All tables, indexes, relations, etc. are correctly upsized, except one table refuses to cooperate. This table is an OLE object field, which contains picture data. If I remove this field, the table can be upsized. Apparently, the upsizing wizard is unable to make the transition. Is there a way around this dilema? create the table with out the old field then create a append query and add the field use the image data type. now you can append the missing data Hope this helps "wschlichtman" <wsc...

PK and FK Displayed
I am a complete Visio newbie, and cannot find the answer I need in books or online help. I am trying to create ER diagrams from scratch, and not connected to real tables, using VEA. I have added tables ('Entities') to the form, connected them with a Relationship connector, and, in the Database Properties window I've assigned the end points to a Primary Key on the left and a Foreign Key on the right. But the model shows the connector as running between the top colums on both sides, whereas I want the keys to be in that upper box and provide the connector's end points. Wh...

C2664 can not convert from char[4] to char[]
I have a array and a function which take a char array as a parameter char chs[4]; void func(char [] para) { comecode; } func(chs); when i try to call func, I got a compile error C2664 can not convert from char[4] to char[], how should i do this function call? OS: Windows xp Compiler:MS VC8 Thanks. On Oct 26, 4:11 pm, sevenever <sevene...@gmail.com> wrote: > I have a array and a function which take a char array as a parameter > > char chs[4]; > > void func(char [] para) > { > comecode; > > } > > func(chs); > > when i try to call func,...

Layaway report #4
I might just be missing it, but does RMS/HQ have a report which gives a date of payments a customer made on his layaways? They don't show up as purchases. Also, I'm looking for a report which would give me inventory valuation as of a certain date (like 12/31/07). A couple of taxing authorities need that information! Jennifer This is a multi-part message in MIME format. ------=_NextPart_000_00D6_01C8C24B.D14142F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Jennifer, http://tinyurl.com/42qqo for Layaway Payments includ...

Formulas are displayed, results are not
Hello, For some reason, when I enter a formula into a cell and press enter, the formula just stays there. Anyone know what I can do to show the results? I tried pressing Cntrl + `, but that didn't work. FYI, when I cut and paste a column from a separate workbook, that column works like normal (i.e., the formulas produce results). Thanks for any suggestions! Hi Mike, Maybe your cell is preformatted as Text. Try formatting to general then erase your = and type it in again. HTH Martin "Mike C" <js2k111@yahoo.com> wrote in message news:f699bcd4-ad82-4a88-9759-5638c147b...

reading data from Excel Sheet
hi, i want to read the data from the Excel sheet using vc++6.0. How can i read it. i don't want to create any DSN thank you, regards, koti You can use the Excel.Application com object -- Satish "Koti" wrote: > hi, > > i want to read the data from the Excel sheet using vc++6.0. How can i > read it. i don't want to create any DSN > > thank you, > > regards, > koti > > > ...

Stop displaying a line
I have a line graph/chart and it gets its values using a formula and the values of another column. However this poses a problem because if there is nothing in the targetted column the formula returns 0 cause the line to drop to the bottom, instead of casuing the line to just end until a value is added to the target column. How can I do this? Change your formula to use NA() if the cell is empty. For example: =IF(A1="",NA(),A1) To hide the resulting #N/A errors on the worksheet, you can use conditional formatting. There are instructions here: http://www.contextures.com/xlC...

Multiple email addresses #4
I recently went from Outlook Express to Outlook, importing my Address Book as I went. However, when I am in Outlook, I can only see one email address per contact. That is, if I have two email address for one contact, I can only see the primary one in Outlook. How do I correct? Do you have separate contact items for the several addresses or what? --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, all mail sent to my personal account will be deleted without reading. After searching google.gr...

Service pack 4
I am planning to upgrade Ex 5.5 sp3 to sp4 I have downloaded all the files but What to find more documentation or advice aon how to do these easily. It's an old nt 4 server with little space any advice? Make as much free space as possible - then apply. Just make sure AV is updated and you should be good. Once applied run Performance Optimizer and just make sure to set the paths to be the same as current. Then install this if your going to have people using Outlook 2003. http://www.microsoft.com/downloads/details.aspx?FamilyID=9EA49782-26B4-470E-950C-3CDCFDC27211&displaylang=en ...

unattached textboxes disappear when a msgbox is displayed on a tab control
I'm using Access 2003. I have a form with a tab control on it. I was having problems with labels flashing and I followed the suggesting from Allen Browne - http://allenbrowne.com/ser-46.html. The flashing went away but now when a msgbox is displayed the unattached textboxes that I'm using as labels disappear. They come back as soon as the msgbox is removed from the screen. I've searched google looking for an answer but have come up short. Does anyone know why I'm experiencing this behavior and how to make it go away? Thanks, Rick That *is* strange. Have you tr...