//flex table opened by JP

Click to See Complete Forum and Search --> : MS Access quarterly data query


Euthorus
05-27-2005, 06:17 PM
This may sound like a silly question - but here it is. I have been trying everything known to me to pull quarterly data from my access db. I could hardcode the dates but then as the year lapses the values have to be changed manually.

Trying things like :

WHERE (((logcodes.COMMENT_DATE) Between #1/4/2005# And DateAdd("m",3,Date()))) works but I really want something that pulls from a given quarter in the current year instead. Does anyone happen to have a better idea ? Thank you in advance.

ScaryBinary
05-30-2005, 10:04 PM
DatePart("q", Date()) will return an integer specifying the quarter in which the current date falls. You could give something like that a shot....

WHERE DatePart("q", logcodes.COMMENT_DATE) = DatePart("q", Date())

for starters. You'll have to restrict the records to the current year as well...

WHERE DatePart("q", logcodes.COMMENT_DATE) = DatePart("q", Date()) AND Year(logcodes.COMMENT_DATE) = Year(Date())

would probably do the trick. The "DatePart" portion will return the records that occur in the same quarter as the current date, and the "Year" part will restrict the records to the current year (otherwise, if it's the 2nd quarter of 2005, you'd get all records that occurred in the 2nd quarter of any year).

Search the Access VBA help files for info on the DatePart function (I couldn't find anything too useful on the MSDN site....)

Euthorus
05-31-2005, 11:20 AM
I have tried every way I could think of plugging DatePart ("q" , xxx,xxx) - and nothing worked :eek:


ScaryBinary

Man, you are awesome, thank you kindly for your help !

SYSOPT FTW !!!:t