View Full Version : DCount with a date range greater than X


Haystakk
03-03-2008, 04:50 AM
Hi,
The query statement below is meant to extract the number of References with a type code of 'M' on the table tblHDRef, then present it under a column named 'Modified':

Modified: DCount("[tblHDRef].[HD Ref]","[tblHDRef]","[tblHDRef].[HD CodeType]='M'")

This works fine - but how can I add further criteria to this query statement to only count references with a HD Date greater than 03/02/2008?

I tried:
Modified: DCount("[tblHDRef].[HD Ref]","[tblHDRef]","[tblHDRef].[HD CodeType]='M' and [tblHDRef].[HD Date]>#03/02/2008#")

but this didn't seem to work at all. Am I missing something?

Cheers in advance.

Dennisk
03-03-2008, 04:57 AM
you need to substitute the actual date value .

DCount("[tblHDRef].[HD Ref]","[tblHDRef]","[tblHDRef].[HD CodeType]='M' and [tblHDRef].[HD Date]> " & #03/02/2008#)

Haystakk
03-03-2008, 05:31 AM
Thanks, but the change to the code returns the total number of References with a type code of 'M' for all dates, not the ones with a date stamp of 04/02/2008 or greater ...

Haystakk
03-03-2008, 07:48 AM
Now seems ok. The issue appears to be as it's using American dates on my UK machine. Is there a localisation setting that needs changing in Access to correct this?

Dennisk
03-04-2008, 12:11 AM
What I have found is that when comparing dates in sql always convert the date to US format

FORMAT(MyDate,"mm/dd/yyyy")