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!

Formatting null dates for display in VB.Net

Status
Not open for further replies.

ProtocolPirate

Programmer
Joined
Nov 21, 2007
Messages
104
Location
US
I tried doing a "SELECT IFNULL(DateField, '1111-1-1')" as well as "SELECT IFNULL(DateField, CAST('1111-1-1' AS DATE))" but I always get the following errors:

[ODBC Engine Interface]Error in row.
[ODBC Engine Interface]Invalid date, time or timestamp value.
[ODBC Engine Interface]Expression evaluation error.

How can I format a date field so that my VB.Net program doesn't blow up on null date fields?
 
FYI IFNULL and CAST aren't Access VBA. Maybe get better guidance in the vb.net forum?

"Before you criticize someone, you should walk a mile in their shoes.
That way, when you criticize them, you're a mile away and you have their shoes."
 
They aren't VB.Net, they are SQL statements.
 
IFNULL and CAST are SQL statements, just like the SELECT command I also mentioned. It is not VB.NET. My questions has nothing at all to do with VB.NET, I should not have even mentioned it, it was obviously only a distraction.
 
Unfortunately, these are not Jet SQL. Is you database SQL Server or Access?
 
I think you'll have better luck in Microsoft SQL Server: Programming Forum.

"Before you criticize someone, you should walk a mile in their shoes.
That way, when you criticize them, you're a mile away and you have their shoes."
 
I believe the correct syntax in SQL Server is:
Code:
  SELECT I[b][red]S[/red][/b]NULL(DateField, '1111-1-1')

Duane MS Access MVP
 
Yup, and there is also its evil twin, NULLIF.

"Before you criticize someone, you should walk a mile in their shoes.
That way, when you criticize them, you're a mile away and you have their shoes."
 
IIF() & Nz() functions are too there in access

________________________________________________________
Zameer Abdulla
Help to find Missing people
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top