DATEDIFF function problem

  • Thread starter Thread starter WB
  • Start date Start date
W

WB

The expected results of a query using the datediff function as part of the
criteria is causing a problem

This works properly: DateDiff("d",t3.TransactionDate, now()) > 150

This doesn't work properly: DateDiff("d",t3.TransactionDate, now()) >
[Enter Days]


Does anyone have information on why there is a difference?

Thanks in advance
WB
 
I suspect that Access/Jet is guessing wrong about the data type of [Enter
Days]. Try specifying by adding the following line to the start of the SQL
view (i.e. prior to SELECT ....)

PARAMETERS [Enter Days] Short;
or
PARAMETERS [Enter Days] Long;

The options are for an Integer or Long Integer data type. You can also do
this in Design view by going to Query|Parameters... and typing in [Enter
Days] under the Parameter column and picking a data type.
 
Thanks, worked perfect.
Wayne Morgan said:
I suspect that Access/Jet is guessing wrong about the data type of [Enter
Days]. Try specifying by adding the following line to the start of the SQL
view (i.e. prior to SELECT ....)

PARAMETERS [Enter Days] Short;
or
PARAMETERS [Enter Days] Long;

The options are for an Integer or Long Integer data type. You can also do
this in Design view by going to Query|Parameters... and typing in [Enter
Days] under the Parameter column and picking a data type.

--
Wayne Morgan
MS Access MVP


WB said:
The expected results of a query using the datediff function as part of the
criteria is causing a problem

This works properly: DateDiff("d",t3.TransactionDate, now()) > 150

This doesn't work properly: DateDiff("d",t3.TransactionDate, now()) >
[Enter Days]


Does anyone have information on why there is a difference?

Thanks in advance
WB
 
Back
Top