[AccessD] Date Comparison Problem

Gustav Brock Gustav at cactus.dk
Fri Mar 31 03:55:07 CST 2006


Hi Stuart

That will work as well but for dates only - a time part will be lost which, however, may be exactly what you wish.
If you need the time part just add TimeValue:

...fldManpowerDate = DateValue('" & datCurrentDate & "') + TimeValue('" & datCurrentDate & "').....

The reason why this works is that the date/time variable is converted to a localized string expression (that was Rocky's problem). But this is exactly what DateValue (and TimeValue) expects. Feeding an English string like "10-oct-2006" to DateValue in a localized environment will cause a syntax error.

/gustav

>>> stuart at lexacorp.com.pg 30-03-2006 23:56 >>>
On 30 Mar 2006 at 9:03, Rocky Smolin - Beach Access S wrote:

> Well I spoke (or wrote) a little too soon.  There's another statement,
> preceding the others which works right in US date format but not in UK
> format.  The statement reads:
> 
>     rstManpower.FindFirst "fldManpowerDate = #" & datCurrentDate & "# 
> AND " _

Access SQL likes it's dates in US format.

To get around the problem where the PC can have any regional setting, I 
always use:
...fldManpowerDate = Datevalue('" & datCurrentDate & "').....
when building these sorts of strings.


-- 
Stuart




More information about the AccessD mailing list