> In access one way of comparing whole days in a DateTime field is with
> DateValue() thus:
>
> SELECT X,Y,Z
> WHERE datevalue(UPDATED) = #createOdbcDate(mydate)#
>
> unfortunately the dateValue() function doesn't exist in MS SQL so
> another way to do it is:
>
> SELECT X,Y,Z
> WHERE datediff(d,UPDATED,#createOdbcDate(mydate)#) = 0
> My question: Is this an effecient way of doing it, or is there a better
> way?
No. It is very unlikely that any database will be able to use an
index for that query (look at the query plan to know for sure).
From the perspective of performance it is probably better to use:
SELECT X,Y,Z
WHERE UPDATED BETWEEN <cfqueryparam cfsqltype="cf_sql_date"
value="#mydate#"> AND <cfqueryparam cfsqltype="cf_sql_date"
value="#DateAdd('d', 1, mydate)#">
Jochem
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

