Reputation: 5047
In my DB, there is a non-nullable Date column. When I provide no date, the value reads 0001-01-01.
However, in the client, I need to know when the column is empty, and for that I use a silly condition:
if (Record.Year == 1)
{
///the column is empty, show "N/A" for date
}
Isn't there a more elegant way than this (the DB column cannot be changed)?
Upvotes: 1
Views: 1191
Reputation: 65304
By chosing to define that column NOT NULL
you told the database, that there always needs to be a (presumably valid) date there. If this doesn't fit your business logic, then you have only two possibilities:
ALTER TABLE tablename MODIFY COLUMN ...
)Upvotes: 4