Click here to Skip to main content
15,794,980 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, i want to reset DateTime values for my database in a C# program but it seems DateTime can't be nulled. Any advice on how to do it or if not how to reset the DateTime value? Thanks in advance.
Thanks7872 23-Oct-13 2:23am    
What do you mean by "reset DateTime value"?
Timberbird 23-Oct-13 2:25am    
DateTime is a structure, so yes, it can't be nulled. You could try using DateTime.MinValue as a special "non-defined date and time" value
YourAverageCoder 23-Oct-13 2:26am    
Thanks. I would have rated your answer but i can't since it's posted as a comment.
Sergey Alexandrovich Kryukov 23-Oct-13 2:35am    
I'm sure this is a wrong answer. Please see my comment.
Timberbird 23-Oct-13 2:40am    
Glad I could help. It's just the first thing that came to my mind - possibly there's a better solution (like using nullable DateTime, i.e. "DateTime?" - it's possile, but I'm not sure which is more suitable for you)

This is a structure, a value type and hence is not nullable. You can make a member or a variable of System.DateType nullable if you use the type System.DateType? instead:
System.DateType? myTime = null;


if (myTime == null) //...

Please see:[^].

Semantically, it looks like you complement the value set of any non-nullable type with one extra point: null value, that's all. I don't advise to try to use "reset value" (like default(System.DateTime)). The default value is a valid point of time, it cannot be considered as "no time". Don't use it, better use the nullable type.

Share this answer
BillWoodruff 23-Oct-13 3:44am    
Excellent +5
Sergey Alexandrovich Kryukov 23-Oct-13 9:26am    
Thank you, Bill.
Hi ,

You can send a value to data base using


Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900