Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SmallDateTime.MinValue??

0 views
Skip to first unread message

Marc Pelletier

unread,
Jan 4, 2005, 11:25:07 PM1/4/05
to
Hello all,

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

Nicholas Paldino [.NET/C# MVP]

unread,
Jan 5, 2005, 9:29:56 AM1/5/05
to
Marc,

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...

Marc Pelletier

unread,
Jan 5, 2005, 9:47:19 PM1/5/05
to
"Nicholas Paldino [.NET/C# MVP]" <m...@spam.guard.caspershouse.com> wrote
in news:OqY7VMz...@TK2MSFTNGP11.phx.gbl:

> 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

0 new messages