R
RichatPlym
Hi, I've found lots of excellent help from this site and everyone seems very friendly so i'd like to post a question. I'm fairly new to access and have created a database to produce reports on a date basis. I want to report quarterly and ideally have code within the SQL for the query to use a system date to do this. i.e hard coding the date would mean editing the code each year.
So far i have come up with this (mostly with help from here)..
SELECT tblX.ID, tblX.StartDate, tblX et
FROM tbl
WHERE (((tblX.StartDate) Between DateSerial(Year(Date()),Month(1),1) And DateSerial(Year(Date()),Month(4),0)))
Theory being this will produce a report for dates between Jan and Apr. However it appears not to work. Hardcoding is fine but I'm puzzled as in the SQL statement the date format needs reversing to how it appears in the table definition. (bit like american and english formats). i.e 15th jan in tblX is 15/01/2004 but in SQL needs coding as #1/15/2004# to obtain results
Hopefully that all makes sense, is this an access issue with date formats? Worse case then i will have to hard code the dates but it'd be nice to have it automated
Many thanks in advance for your hel
Rich
So far i have come up with this (mostly with help from here)..
SELECT tblX.ID, tblX.StartDate, tblX et
FROM tbl
WHERE (((tblX.StartDate) Between DateSerial(Year(Date()),Month(1),1) And DateSerial(Year(Date()),Month(4),0)))
Theory being this will produce a report for dates between Jan and Apr. However it appears not to work. Hardcoding is fine but I'm puzzled as in the SQL statement the date format needs reversing to how it appears in the table definition. (bit like american and english formats). i.e 15th jan in tblX is 15/01/2004 but in SQL needs coding as #1/15/2004# to obtain results
Hopefully that all makes sense, is this an access issue with date formats? Worse case then i will have to hard code the dates but it'd be nice to have it automated
Many thanks in advance for your hel
Rich