Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

null in date field

Status
Not open for further replies.

darkwraith

Programmer
May 26, 2003
44
IT
Hi, I have to insert/update a record in my table.
Sometimes it happens that the value of some fields are null.
I use iif(isnull(myfield), "", myfield.value) in my sql instruction when the field type is string.
It doesn't work with dates (an error occurs: type conversion error).
Which is the correct statement?
Thanx,
Elena
 
Elena:

Try

iif([myfield] is null, "", myfield.value)

The syntax for the IsNull function is slightly different in an immediate If statement.

HTH

Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
I would use the nz() function. It does the same thing, but it's a lot prettier.

==
Jeremy Wallace
AlphaBet City Dataworks
Professional Development for Clients Large and Small

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Thanks, I'll try with is null and nz() function instead of my code,
Elena
 
Hi darkwraith,

Jeremy is right. Use the Nz function - it's really just a neater way of saying iif(isnull...

But I think the reason for your problem is that you are supplying an empty string as the 'default' date when you should be providing a date.

Enjoy,
Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top