IIF AND VARCHAR FIELD

G

Ghena

Hi I have this query

SELECT advanced.codoff, advanced.entro_il,
IIf(InStr([advanced]![entro_il],"/"),DateDiff("\d",([advanced]![entro_il]),Date()),[advanced]![entro_il])
AS Espr1
FROM advanced
WHERE (((advanced.codoff)=261));

the field [advanced]![entro_il] is a text field.
But is possible that it get a date value or a numeric value
Actually I have an erorr in the field of the expression in wich is
present a date value
E.s. 20/03/06
DateDiff("\d",([advanced]![entro_il]),Date())

on the contrary if the field is numeric access display the value
[advanced]![entro_il]

I tryed using the prefix ISdate as below, but it doesn't work.

IIf(InStr([advanced]![entro_il],"/"),DateDiff("\d",(Isdate([advanced]![entro_il])),Date()),[advanced]![entro_il])

Bye...
 
J

Jeff Boyce

Ghena

I am unfamiliar with the use of "\d" in the DateDiff() function. I am
familiar with using "d". What is your intended purpose of adding the "\"?

--
Regards

Jeff Boyce
Microsoft Office/Access MVP
Microsoft IT Academy Program Mentor
 
G

Ghena

Acces change automatically the value "d" with "\d"

but it works now..
thanks

SELECT advanced.codoff, advanced.entro_il,
IIf(InStr([advanced]![entro_il],"/"),DateDiff("d",Date(),([advanced]![entro_il])),[advanced]![entro_il])

AS Espr1
FROM advanced
WHERE (((advanced.codoff)=261));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top