Pretty sure - when I show the values without trying a compare, I don't see
anything wrong, and when I change the query to spin the DateDiff value out
to a table, the table contains only valid integers, positive and negative. I
can subsequently sort on that integer column and see that there is nothing
bad at either end. I can also select only the positive ones to get the
records I want, but creating an unnecessary temp table is an awkward way to
do it. The comparison should work.
Pete
"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_gmail.com> píše v diskusním
příspěvku news:(E-Mail Removed)...
> You sure you've got valid values for both fields in every row?
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Petr Danes" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I just tried the last query in another form, using a direct comparison
>>instead of the DateDiff function. Same error.
>>
>> SELECT Stvoreni_Convert.DatumStvoreni, CDate([DatumStvoreni]) AS Rozdil,
>> Stvoreni_Convert.AkcesPodrobnostiAutoID INTO STV
>> FROM Stvoreni_Convert
>> WHERE (((CDate([DatumStvoreni]))>CDate([From date])));
>>
>> Pete
>>
>>
>>
>> "Tom Lake" <(E-Mail Removed)> píse v diskusním príspevku
>> news:(E-Mail Removed)...
>>>
>>> "Petr Danes" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> I have a set of queries that generate dates and want to use DateDiff to
>>>> select those records with certain dates are greater than others. The
>>>> following clause keeps giving me an incompatible data type error:
>>>>
>>>> WHERE DateDiff('d',[From date],[DatumStvoreni])>0
>>>>
>>>> I have the exact expression in the SELECT clause and it show positive
>>>> and negative integers just fine, but when I add this test, I get the
>>>> error. There are no bad values in the dataset, I've looked, and when I
>>>> export the DateDiff column to a temp table and run a query on that, it
>>>> works fine. Only when I use the test directly with the DateDiff
>>>> function does it bomb. I also tried putting CDate() around the field
>>>> expressions and it didn't help.
>>>
>>> I get an error when I use single quotes. I have to use this:
>>>
>>> DateDiff("d",[From date],[DatumStvoreni])
>>>
>>> The whole expression I tried was this:
>>>
>>> WHERE (DateDiff("d",[From date],[DatumStvoreni])>0)
>>>
>>> Tom Lake
>>>
>>>
>>>
>>
>>
>
>