Yeah but can I do it directly in my SQL query? Your example uses VBA (the
cast to long I mean)... does access allow VBA mixed with SQL in queries?
If so could you please show me an example...? Otherwise are you suggesting I
preprocess the data and then use those results to build the final query?
I haven't used Access for many years (prefer proper SQL Server environment
with VB, VB.Net or C# over Access) which is why I am not sure how to
approach this. I've been stuck with the job of expanding a poorly designed
and clunky old Access database. Personally I'd rather rewrite using .Net and
SQL or MSDE but don't have that luxury right now. So, I have to do it the
hard way (hard because my knowledge of Access is very outdated).
Cheers for the info
John Viescas said:
You can calculate "weeks ago" like this:
WeeksAgo: CLng(Date() - [DateSent]) \ 7
You can then use that expression as a column or row heading in a crosstab.
--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
Some Guy said:
Hi there,
I have a table with these fields:
Location, DateSent, Case Number
This records case files that have been sent to a location and the date sent.
I am trying to do a report showing case files sent a certain number of weeks
ago... kind of like the 30 day, 60 day, 90 day overdue section on some
statements.
I want to create a crosstab (if poss but not necessary) query for a report
which does the following:
Lists Locations (if crosstab as column headings)
List CaseNumber (if crosstab as the column value)
Lists DateSent (if crosstab as row headers) BUT not as the actual date...
instead I want rows showing 1 week, 3 weeks, 5 weeks, 7 weeks, and 9
weeks...
Any idea how I can achieve this? I could do this in an SQL stored procedure
in a snap but I think Access will require me to do it all in the SELECT
statement. Buggered if I can figure out how though...
The format for the crosstab query I am going for is something like:
Location A Location B Location C
1 week Case1 Case2 Case3
3 weeks
5 weeks
...
Failing that I'd be happy with:
Location A
1 week Case1
3 weeks Case2
Case3
5 weeks Case 4
LocationB
1 week etc etc etc
I hope this formats ok when you guys view it....
Cheers in advance for any suggestions...