PC Review


Reply
Thread Tools Rate Thread

Days of the month

 
 
kevcar40
Guest
Posts: n/a
 
      8th Apr 2011
Hi
I have created a crosstab query based on the user selecting a year and month on a user form

what i would like to do is order the result in the date order for the month

ie if April selected from 1/4/11 to 30/4/11 in the Column header
if March selected from 1/3/11 to 31/3/11 in the Column header

is this possible ?

thanks

kevin
 
Reply With Quote
 
 
 
 
John Spencer
Guest
Posts: n/a
 
      8th Apr 2011
Yes it is possible.

Simple solution would be to have a table with all the dates in it that are
relevant for your data. One record for each day in the range. Then join that
to your query. WIthout seeing your current query's SQL statement I can only
give you a generic query as an example.

Parameters [YearValue] Long, [MonthValue] Long;
TRANSFORM Sum(X)
SELECT Y
FROM CalendarTable LEFT JOIN YourTable
ON CalendarTable.TheDate = YourTable.SomeDateField
WHERE CalendarTable.TheDate between DateSerial([YearValue],[MonthValue],1)
AND DateSerial([YearValue],[MonthValue]+1,0)
GROUP BY Y
PIVOT Format(CalendarTable.TheDate,"dd/mm/yy")

You could also do something similar with a table that contained rows with the
number from 1 to 31 and use that to calculate the days of the month.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

On 4/8/2011 6:19 AM, kevcar40 wrote:
> Hi
> I have created a crosstab query based on the user selecting a year and month on a user form
>
> what i would like to do is order the result in the date order for the month
>
> ie if April selected from 1/4/11 to 30/4/11 in the Column header
> if March selected from 1/3/11 to 31/3/11 in the Column header
>
> is this possible ?
>
> thanks
>
> kevin

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel to make the days cary over month to month automaticly GARY Microsoft Excel New Users 1 19th Apr 2008 06:05 PM
Number of days in month counted from shortened name of month & yea =?Utf-8?B?VHVtYXI=?= Microsoft Excel Worksheet Functions 6 18th Sep 2007 03:36 PM
Days per month for calculating storage days Bart Microsoft Excel Worksheet Functions 3 31st Jan 2007 06:40 PM
how do i differentiate 31 days month from 28 days month =?Utf-8?B?a3dha3M=?= Microsoft Access Queries 6 24th Apr 2006 07:27 AM
formula for days in month - days left??? Jason Microsoft Excel Programming 3 23rd Aug 2003 09:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:56 AM.