Share via

#Error return value in date field HELP

Anonymous
2011-10-05T17:45:02+00:00

Hello,

I have a date/time field called "compdatetime" in my database. There are blank record in the compdate field.

I am trying to convert the date/time stamp field to just date only which I use compdate=DateValue(compdatetime).

I worked only the records with value. Any record without value is returns #ERROR.

How I can fixed this problem so instead of return #ERROR, return blank/ empty? I tried IIF statement, but it didn't work.

=IIF(compdatetime is not null, DateValue(compdatetime),"")

This does return blank on record without value, except it return the date as text field. THANKS

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2011-10-05T18:33:44+00:00

Try this --

=IIF(IsDate([compdatetime]), DateValue(compdatetime),"")

           Or --

=IIF(IsDate([compdatetime]), DateValue(compdatetime), Null)

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2011-10-05T18:42:38+00:00

    =IIF(compdatetime is not null, DateValue(compdatetime),"")

    Try incorporating the ISNULL() function in the criteria of your IIF() function.

    SELECT IIF(ISNULL(dt.compdatetime),"", DATEVALUE(dt.compdatetime)) As [Just the Date]

    FROM tblDateTime AS dt;

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2011-10-05T18:40:42+00:00

    Thank Karl,

    The second option worked. The first didn't.

    Was this answer helpful?

    0 comments No comments