"Invalid Use Of Null" using CDate

Posted on 2004-10-08
Last Modified: 2008-02-01
Hi All,

I have a date/time field in a table which is converted within a query from a string value via the following:

New Date Field: Int(CDate([Original Date Field]))

The problem is, I cannot view the query in design view if any records do not have data within the date field -- I get a "Invalid Use Of Null" error message.  This field will not always contain data, therefore, I need some way to work around this.


Question by:MICHAED
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 52

Assisted Solution

by:Ryan Chong
Ryan Chong earned 50 total points
ID: 12261748

New Date Field: IIF(IsDate([Original Date Field]) ,  Int(CDate([Original Date Field])) , 0)
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 50 total points
ID: 12261852

New Date Field: IIF(([Original Date Field])Is Null ,"",  Int(CDate([Original Date Field])))

Author Comment

ID: 12261857

I'm getting "Invalid Operator" so I'm trying to find the expression's error....
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 11

Expert Comment

ID: 12261869
Alternatively, you can avoid the IIF function by using:
     Format(Nz([Original Date Field], ""), "mm/dd/yy")

Author Comment

ID: 12261945
Jokra, will your function convert my date/time field ...or leave it as a string?

Author Comment

ID: 12261978
Folks, I've tried all suggestions -- and I do not get the error anymore.  However, the sort order is appears that the field is sorting like a string field rather than a date field.
LVL 41

Accepted Solution

shanesuebsahakarn earned 150 total points
ID: 12262000

New Date Field: IIf(IsNull([Original Date Field]),Null,Int(CDate([Original Date Field])))

Author Comment

ID: 12262032
Shane's version worked -- thanks all!


Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question