• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 369
  • Last Modified:

LINQ HOW TO SET DEFAULT MIN VALUE IN SMALDATETME COLUM

Came across a problem with nullable datetime columns and linq query.   Essentially I cannot query on datetime if the field is null in the database.

What is the best approach when adding a customer record with linq to sql server and setting a default value for the Date of Birth (DOB) column.

For the user the DOB is optional but I need to do a query that will return all records that have a DOB say greater than 1955.  

So what I need is a default value that is set and cannot be a valid date of birth but will also work with a linq query

For example

          var Data = from qryData in ReportData
                         where (qryData.DOB >= DOB)
                         select qryReportData;

0
mugsey
Asked:
mugsey
1 Solution
 
Bob LearnedCommented:
The DateTime.MinValue is 1/1/0001 12:00 am, and can be used in place of NULL in a database.
0
 
mugseyAuthor Commented:
Thanks Bob
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now