date format in expression

B

Brian

I have a report that is derived from an iif expression within a query. -
=iif([NAdate]=true,"NA",[date])

The report field always returns the date in the MM/DD/YYYY format. I Just
want to display the M/D format (which works fine on the fields that are not
expressions) regardless of whether I have entered M/D in the format
properties of either the report and/or query field. What am I missing?

Thanks
Brian
 
T

tina

try using the Format() function to explicitly format the date value, as

=IIf([NAdate]=true,"NA",Format([date], "m\/d\/yyyy"))

hth
 
B

Brian

Ok, that works - thanks

Now my question is why will it not accept the format properties of the
field - or is that one of the quirks we are supposed to live with?


tina said:
try using the Format() function to explicitly format the date value, as

=IIf([NAdate]=true,"NA",Format([date], "m\/d\/yyyy"))

hth


Brian said:
I have a report that is derived from an iif expression within a query. -
=iif([NAdate]=true,"NA",[date])

The report field always returns the date in the MM/DD/YYYY format. I Just
want to display the M/D format (which works fine on the fields that are not
expressions) regardless of whether I have entered M/D in the format
properties of either the report and/or query field. What am I missing?

Thanks
Brian
 
A

Allen Browne

Access can only apply the Format property if the field consistently contains
a date. NA is not a date.

Tina's workaround solves the problem because the Format() function spits out
text too.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.
Brian said:
Ok, that works - thanks

Now my question is why will it not accept the format properties of the
field - or is that one of the quirks we are supposed to live with?


tina said:
try using the Format() function to explicitly format the date value, as

=IIf([NAdate]=true,"NA",Format([date], "m\/d\/yyyy"))

hth


Brian said:
I have a report that is derived from an iif expression within a query. -
=iif([NAdate]=true,"NA",[date])

The report field always returns the date in the MM/DD/YYYY format. I
Just
want to display the M/D format (which works fine on the fields that are not
expressions) regardless of whether I have entered M/D in the format
properties of either the report and/or query field. What am I missing?
 

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