I have a library of datetime routines that make things simpler for me.
Before I discovered DateTime.MinValue I had a function that looked like
public static DateTime DayZero { get { return new DateTime( 0,0,0); } }
I use it to compare for nonvalid datimes in some code, for example if
moonrise equals DayZero then the moon doesn't rise on that day.
Now I am SOOO much smarter and I refer to DateTime.MinValue instead. Is
there a simple way to get the equivalent result for a smalldatetime field?
Right now I am using
public static DateTime SmallDayZero {get {return new DateTime(1900,1,1);} }
to test if a value will fit into the smalldatetime field in a database, but
I suspect there is a better way.
Any ideas?
Thanks
Marc Pelletier
This is probably the best way to do it. If anything, you should set the
SmallDayZero field to be readonly, so that it can't be changed by your
application (it's not ever going to change).
The SqlDateTime structure is used to represent both regular datetime
values and smalldatetime values in .NET, so you can't use the Min on that.
You will have to define it yourself.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
"Marc Pelletier" <no.e...@please.com> wrote in message
news:Xns95D4E40D...@216.168.3.44...
> The SqlDateTime structure is used to represent both regular
> datetime
> values and smalldatetime values in .NET, so you can't use the Min on
> that. You will have to define it yourself.
>
> Hope this helps.
>
It does, thanks.
Marc