I have been facing problems since started writing queries against previious months, years, days etc.
I wrote the following query to get the previous 12 months which is working fine but the Order of months giving me problem
Suppose if I run today the query I should get months from Oct 2008 till Oct 2007. And the order should be
Oct 2007,Nov 2007, Dec 2007, Jan 2008, Feb 2008, Mar 2008 till Oct 2008
Please help me how to get into there.
Here is the query I am using
SELECT
Format$(tbl.cDate,'mmm yyyy')
FROM
tbl
WHERE
( tbl.cDate Between DateAdd('m',-12,DatePart('m', Date()) & '/1/' & DatePart('yyyy', date())) AND Dateadd('d',-1, DatePart('m', date()) & '/1/' & DatePart('yyyy', date())) )
GROUP BY
Format$(tbl.cDate,'mmm yyyy')
I wrote the following query to get the previous 12 months which is working fine but the Order of months giving me problem
Suppose if I run today the query I should get months from Oct 2008 till Oct 2007. And the order should be
Oct 2007,Nov 2007, Dec 2007, Jan 2008, Feb 2008, Mar 2008 till Oct 2008
Please help me how to get into there.
Here is the query I am using
SELECT
Format$(tbl.cDate,'mmm yyyy')
FROM
tbl
WHERE
( tbl.cDate Between DateAdd('m',-12,DatePart('m', Date()) & '/1/' & DatePart('yyyy', date())) AND Dateadd('d',-1, DatePart('m', date()) & '/1/' & DatePart('yyyy', date())) )
GROUP BY
Format$(tbl.cDate,'mmm yyyy')