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  dBforums > PC based Database Applications > Microsoft Access > Sorting/Formating Dates in Cross Tab Query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-01-12, 10:54
cmelias cmelias is offline
Registered User
 
Join Date: Jun 2009
Posts: 48
Sorting/Formating Dates in Cross Tab Query

I am making a crosstab query where the columns are report dates. I want the columns sorted by date and the format to be mmm, yyyy. The SQL for the query is:

TRANSFORM Count(qryReport.Filed) AS CountOfFiled
SELECT qryReport.Report_Type, qryReport.TO_Number, Count(qryReport.Filed) AS [Total Of Filed]
FROM qryReport
GROUP BY qryReport.Report_Type, qryReport.TO_Number
ORDER BY qryReport.TO_Number
PIVOT CDate(Format([Report_Date],"mmm-yyyy"));

A partial view of the result of the crosstab query is in the attached pdf file.

The qryReport is based on a table where the dates are already formatted as mmm-yyyy. These dates show up formatted this way in a form based on the table and in the datasheet view of qryReport (based on the same table), but in the crosstab query they show up like this:

3/1/2010 4/1/2010 5/1/2010 6/1/2010 7/1/2010 ...

instead of:

Mar-2010 Apr-2010 May-2010 Jun-2010 Jul-2010 ...

The SQL for qryReport is:

SELECT Reports.Report_Type, Reports.Report_Number, Reports.TO_Number, Reports.Filed, Reports.Report_Date
FROM Reports
ORDER BY Reports.TO_Number, Reports.Report_Type, Reports.Report_Date;

I will appreciate any help you can give.

Thanks,

Charles
Attached Files
File Type: pdf qryReport_Crosstab.pdf (39.6 KB, 4 views)
File Type: txt qryReportCrossTabSQL.txt (292 Bytes, 2 views)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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